Editor performance very poor
scotthibbs
Posts: 18
When SQL Prompt is on, editor performance is poor.....particularly when
entering multiple spaces or tabs. Is there any way to auto-indent? This REALLY slows down editor performance.
entering multiple spaces or tabs. Is there any way to auto-indent? This REALLY slows down editor performance.
Comments
-Pete
Yes.....RC 3.5 is much better.
We found that the poor perfomance was in areas that were heavily indented.....as a result of using SQL Refactor.
In non-indented areas, performance is pretty good....3.5 even better.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
For instance, if SQL Refactor reformats the code in a section to be indented to a depth of say 25 spaces....then you go to the middle of
the block and try to add a line. Entering the 25 spaces to get to the
proper location is extremely slow....you lose the cursor for up to a second or two. Completion function also seem slow when you finally get to the right position.
If you turn off SQL prompt off, the effect disappears. I don't know what SQL prompt is trying to do.....it's very strange behavior.
The 3.5 version improves a bit, but it's still very noticeable.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
I took a 600 line SQL script that is mainly composed of SELECT statements against the AdventureWorks 2005 database. I wanted to get SQL Prompt working as hard as possible so I indented everything by 40 spaces to start off with and then headed down to about line 540 where I inserted about 35 newlines and then just held the space bar down to insert loads of spaces.
Meanwhile I had Task Manager open to look at the CPU usage and to be honest, all was well. Using between 5 and 12% CPU right up until I'd got to about column 470 with the space insertion, then the CPU usage jumped up to 30-40% and everything got a little bit on the jerky side.
I still have no idea what's causing this, however it might be useful to know a bit more about your machine:
- OS
- CPU type and speed
- Amount of physical memory
In the meantime I'm going to profile the application to try to see what the problem is.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
I've been able to identify two possible causes for this behaviour:
(i) Our AST parser outputs ASTs where child nodes are implemented as singly-linked lists, which means you can only really walk them in one direction. This causes a problem when we want to try to identify whether there's anything between a particular node and the caret when the caret does not fall exactly within the bounds of a node. Now, our method for checking for non-whitespace characters isn't quite as efficient as it might be and I have found that we are checking multiple times over overlapping ranges of characters.
(ii) If a syntax error is detected that corrupts the AST or causes no AST to be generated we fall back to using regular expressions to try to identify the beginning of any kind of supported SQL statement, and then we perform a recursive descent parse from that position up to the caret position. Now it turns out that this isn't always as efficient as I might like, although the circumstances under which this occurs are less frequent than (i).
I have been able to fairly easily apply a fix for (i) that seems to work well, however although my automated tests pass, and the limited manual testing I've carried out seems to exhibit no side-effects, it's possible that this fix may have unforeseen consequences and since we have already run through around 90% of our other tests I am unwilling to take a chance of breaking something by checking this in at this stage since it's in code that's right in the core of the parsing logic and so obviously this is used extensively by the code that works out what to provide in terms of auto-completion. So this fix will not make it into the 3.5 final release. However once this is out I am happy to provide you with a download link for an installer with a version of SQL Prompt that would include this fix. It probably won't solve your problem completely and I did notice that performance does degrade after I've inserted somewhat more than 1000 spaces on the line in question, which is more than double the number I had to insert before applying the fix.
Problem (ii) is more difficult to solve, although it is solvable, but I certainly won't be fixing it before the 3.5 release because it involves possibly up to 8 hours work and any bugs would certainly result in bizarre side effects elsewhere. It's really too late in the day to be contemplating a fix like that.
In the meantime there are two things you could contemplate doing in order to improve the situation. The first, as Chris jokingly suggested, actually is switch to using tabs rather than spaces. The second is to click on the SQL Prompt > Options menu item. Then go to the Variables and Parameters screen on the Listed Candidates tab and experiment with reducing the value in the Lines field under Search a fixed number of lines from the caret (faster). Despite the name of this field what it really does is define the maximum size of the block of code SQL Prompt will attempt to parse. For reasons too dull to go into it's actually twice this size (number of lines above and below the caret), although most of the time SQL Prompt will actually parse much less. What it does is to specify an outer limit. However be warned: if you make this value too small you may find that the auto-completion list isn't populated properly because SQL Prompt ends up trying to parse partial SQL statements and this breaks the AST generation.
Hope that helps.
Thanks,
Bart
Principal Consultant
bartread.com Ltd
I got the following resulte while testing SP3.5 in a server configured as "Connections to ignore".
After pasting the script in QA, my CPU use goes to 100% by QA. It's ok, SP3.5 is parsing the code, but note:
It is a connection to ignore... Does it make sense to parse this connection?
The most part of the code, is commented code. Again, does it make sense to parse this?
But ok, probably there is a good reason do SP team thinking this behavior. I think we talked about this in SP3.0 beta discussion.
Going ahead.
My question is: if I navigate in the code using the arrows keys, or point the cursor using the mouse, in some parts of the script, no problems. No delays.
But if I put the cursor from columns 1 to end of the first word + blank space , my cpu use goes to 100% again for some moments!!! Too stange!!
Ex->exec sp_rename.... cursor from column 1 to 6
now, (removig exec command form all senteneces) so:
Ex->sp_rename ....cursor from colum 1 to 11
The code (as you can see, there is a lot of blank spaces, no tabs):
Cheers,
Bart
Principal Consultant
bartread.com Ltd