Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 1649: Editor lag/high CPU usage in C++ file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

thethirdhalf
Junior Member

16 Posts

Posted - Oct 16 2008 :  1:57:56 PM  Show Profile  Reply with Quote
I've observed delays upwards of several seconds while editing a C++ file. For example, copying and pasting a small block of code results in a delay of about one second.

My machine is a Pentium D 3.20 GHz, with 4 GB RAM.

The file has the following unique characteristics:
- It is a QT unit test(see here: http://doc.trolltech.com/4.3/qtest.html)
- It uses templates and macros, including QT's unit test framework and QT's template QList, with a nested template QPair in it.

There is only a QObject include in the header, and four QT includes in the source (notably QString), as well as a few other includes, one of which includes 4 more QT includes.

Disabling Visual Assist results in the lag disappearing.

Other files, not having the aforementioned unique characteristics, do not lag at all.

What do you need from me to troubleshoot this issue?

Visual Assist X 10.4.1649.0
Visual Studio 2008 Standard

thethirdhalf
Junior Member

16 Posts

Posted - Oct 16 2008 :  2:01:07 PM  Show Profile  Reply with Quote
I should mention that the solution has just under 10000 files in it, including the QT 4.3.1 include trees for three OS's. There are roughly 2900 QT headers in the project, 405 project source files and another 1000 project headers.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Oct 17 2008 :  09:33:50 AM  Show Profile  Reply with Quote
How big is this problem file? How many lines long?

It is possible the problem is simply due to the file size, if it is very large.

zen is the art of being at one with the two'ness
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 17 2008 :  11:41:32 AM  Show Profile  Reply with Quote
The file is 400 lines long, and I have to disable VAX to work in it the lag is so bad.

I noticed something else:

I am working on a file of about 2800 lines. It was performing completely fine.

I added several dozen constants of the following form and started using them:

const char CONSTANT_1[] = "3234.askldlas";

Editing the file now lags substantially.



Edited by - thethirdhalf on Oct 17 2008 11:41:56 AM
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 17 2008 :  11:49:19 AM  Show Profile  Reply with Quote
Any tips on profiling VS? I don't mind doing this, but I don't have a tool for it. Attempts to use the Intel profiler trial have failed miserably on account of licensing problems...

I'm doing Linux/Solaris dev (with Visual Studio, ironically), so we don't need Windows profilers around my company.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Oct 18 2008 :  1:47:37 PM  Show Profile  Reply with Quote
The first step is to try disabling the IDE's intellisense, as described here:

http://docs.wholetomato.com?W133

Although since disabling VA fixes most of these problems this is unlikely to actually help. Would it be possible to get a copy of one of the problem files you are using? I could then test the file here and see if I can reproduce the problem. If so please submit the files via the form:

http://www.wholetomato.com/support/contact.asp

including this thread ID or URL in the description, so we can match it up. I understand this is often not possible, but it is worth asking.

When you get a problem like this it is normally either a massive file (20 thousand lines or more) or a lot of very nasty template or macro code that is confusing our parser. Sometimes it is possible to "hide" problem code from our parser by using VA's StdAfx.h file. See here for an example of this in action:

http://docs.wholetomato.com?W310

zen is the art of being at one with the two'ness
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 21 2008 :  4:31:29 PM  Show Profile  Reply with Quote
I have submitted a minimal solution in which I have managed to reproduce the issue, as par your suggestion.

Let me know if you didn't receive it, can't find it, etc.

Have a look at testfile.cpp:

I experience lag when writing a new for loop, as an example, or copy-pasting the loops.

...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Oct 22 2008 :  5:05:37 PM  Show Profile  Reply with Quote
I have the solution, thank you for this.

If you run a CPU meter are you seeing a CPU spike when the slow down occurs?
Does it matter what you type, or where you type it in the file?

So far I am not seeing any obvious problems, but my system configuration is probably different to yours.

Can you please go to:

VA Options -> System Info -> Copy Info

and paste the details (from the clipboard) into your reply. This will give us the basic information about your setup.

zen is the art of being at one with the two'ness
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 22 2008 :  5:49:29 PM  Show Profile  Reply with Quote
Thanks for looking into this.

I'm seeing momentary spikes of around 50-60% usage on both cores when the lag occurs.

Scrolling, copy pasting some QVERIFY/QCOMPARE blocks, typing in loops like the following produce this result fairly consistently.

for(int i = 0; i < doubleProperties.size(); i++)
{
}

The location in the file doesn't seem to affect it.

Dragging to select itself results in a noticeable delay. This is particularly interesting, since I'm not even typing. This delay disappears when VAX is disabled.

*****

VA_X.dll file version 10.4.1649.0 built 2008.09.09
DevEnv.exe version 9.0.30729.1
msenv.dll version 9.0.30729.1
Font: Bitstream Vera Sans Mono 13(Pixels)
Comctl32.dll version 6.0.2900.2982
Windows XP 5.1 Build 2600 Service Pack 2
2 processors

Platform: Win32
Stable Includes:
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;

Other Includes:

Stable Source Directories:
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\mfc;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\mfcm;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\atl;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\crt\\src;

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Oct 23 2008 :  12:13:45 PM  Show Profile  Reply with Quote
I am not seeing any mention of Qt in your stable include directories. Are you manually adding all of the required Qt files to each of your solutions?

On my main test solution my VA stable include directories are set to:

Platform: Win32
Stable Includes:
C:\\Qt\\4_4_0\\src;
C:\\Qt\\4_4_0\\include\\Qt;
C:\\Qt\\4_4_0\\include;
C:\\WTL75\\include;
C:\\boost\\boost_1_33_1;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;

Other Includes:

Stable Source Directories:
C:\\Qt\\4_4_0\\src;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\mfc;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\mfcm;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\atl;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\crt\\src;


I added these Qt directories to the IDE's include directories list as described here:

http://www.wholetomato.com/products/features/directories.asp

If you have turned on:

VA Options -> Advanced -> Fonts and Colors -> Stable symbols in Italic

this has the benefit of showing the Qt symbols in italics. On this machine I have deleted all of the Qt header files from your test solution and re-tested it. That turned out to be a bad idea, since it took ages for the IDE to delete the files, it would have been far faster to make a new test project and just add your two code files to it.

If you have the time can you try modifying your IDE include directories, to add the appropriate Qt directories, then tell VA to rebuild its symbol database, and then open this solution:

http://forum.wholetomato.com/colin/forumimages/8270_PerformanceTestSmall.zip

This is just your solution with all of the Qt files deleted.

Do you still see the same problem?

I am wondering if VA having to re-parse the Qt header files when it re-parses the file is a factor. VA knows it does not have to reparse header files in the stable include directories all the time, since they are stable.

zen is the art of being at one with the two'ness
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 23 2008 :  12:27:10 PM  Show Profile  Reply with Quote
"I am not seeing any mention of Qt in your stable include directories. Are you manually adding all of the required Qt files to each of your solutions?"

Yes, that is, for now, part of our requirement.

We have projects that use multiple versions of QT simultaneously - including multiple platforms.

Not only this, but the include directories are not in the same location in every project.

Is it possible that VAX is not able to handle the QT headers being part of the solution directly?

Can the stable include directories feature be used for header files in the solution?

How does the stable include directory feature affect template generation in VAX?

Most importantly, is there a way to automate the addition of directories to the stable include directories?
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 23 2008 :  1:04:19 PM  Show Profile  Reply with Quote
One more thing:

Stable includes aren't solution specific. Let's say one open solution depends on QT3 and another on QT4. The reference will result in an ambiguity between the two since both would have to be in the stable include directories.

This isn't the worst thing in the world, but I'm guessing that there isn't a way around it.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Oct 23 2008 :  1:07:38 PM  Show Profile  Reply with Quote
It is possible that the stable include directories do not matter at all here. I am not seeing a clear, overt problem even with your initial test project, which contains all of the Qt files. I thought this would be an easy, sensible thing to try, but given your situation it is not

Normally when people are using Qt they are only using a single version, so the stable include directories are more straight forward to setup and use

When I scroll through the file I am seeing the CPU usage jump to 100%, but scrolling seems to be happening at normal speed. I am seeing the same CPU usage in a totally different file, in a different project. I believe this is due to VA applying its enhanced syntax colouring to the file as it is being scrolled.

CPU spikes while typing, it is possible this is normal behaviour. When you pause typing VA parses the file, which will cause a very brief CPU spike. This should only happen when you actually pause typing, while you are actively typing VA should not be parsing the file / changes. This is why you need to pause typing to let VA parse and catch up before new variables are recognised, coloured correctly and suggested.

Lets turn to selecting text, hopefully that is easier to test

Using winXP, VS2008, VA 1649 and your original test project on a machine with no Qt directories in the stable include directories (so should be similar to your system) I have opened the "testfile.cpp" file, and jumped to line 81. The caret is at the start of the line, column 1.

If I now use Shift + Down and Up arrow to select several lines of code I am only seeing a CPU spike when the code actually scrolls. If there is no scrolling then the CPU is basically idle. How similar is this to what you are seeing?

zen is the art of being at one with the two'ness
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Oct 23 2008 :  1:57:31 PM  Show Profile  Reply with Quote
"If I now use Shift + Down and Up arrow to select several lines of code I am only seeing a CPU spike when the code actually scrolls. If there is no scrolling then the CPU is basically idle. How similar is this to what you are seeing?"

I see about 10-25%, both cores, while selection is changing. It's about 40% while scrolling.

Since the selection lag seems intermittent over here after playing with it for a while, there is something you could try:

Just copy the code from line 163 to 164.

QVERIFY(charProperties[i].second > 0);
QCOMPARE(integerProperties[i].second, 34);

At this point, my CPU is around 0-6% with my devenv.exe rarely even hitting 1%

Go to line 166. Now hold down ctrl+v.

On my end, the CPU's hit 50% and it takes about a 1/3 second per paste.

After that, undo operations are sluggish. Selection with the mouse is sluggish. Scrolling is sluggish.

I repeated the paste operation with one of the empty for loops. Same effect.

I repeated the same thing in the header file, by just creating a small function (void func() { } ). It is about three times faster to paste the same code. Just pasting a for loop in the header is even faster.

By the way, I often run with four IDE's open, with multi-thousand file projects loaded in each one. I'm testing with no other IDEs right now though.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Oct 27 2008 :  5:51:55 PM  Show Profile  Reply with Quote
How many times do you need to press CTRL-V to trigger the CPU spike when selecting code?

I have pressed CTRL-V 18 times, pasting the code in at line 166, and adding a screen full of this copy / pasted code. On a single core virtual machine the CPU usage was sitting around 60-70% during this pasting, but pasting was happening at normal speed.

Having done this I am not seeing any CPU spike at all on selecting code, so long as I do not trigger scrolling.

I am wondering if there is a problem with VA's symbol database. I don't see why this would cause these problem, but obviously something is.

With just this one IDE open can you please press the button:

VA Options -> Performance -> Rebuild symbol databases

then restart the IDE and load this test solution. The rebuild should only take a couple of minutes. Do you still see these problems?

If you do can you try closing the IDE and deleting the NCB file in the root directory of the solution and then reloading the IDE. The IDE will rebuild this file - which is used for the IDE's intellisense when you reload the solution.

zen is the art of being at one with the two'ness
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Nov 04 2008 :  5:15:23 PM  Show Profile  Reply with Quote
Sorry for the late reply... I've been busy.

"I have pressed CTRL-V 18 times, pasting the code in at line 166, and adding a screen full of this copy / pasted code. On a single core virtual machine the CPU usage was sitting around 60-70% during this pasting, but pasting was happening at normal speed."

I just held it down. It began to lag, and editor window operations became significantly slower. Automatic bracket creation is laggy, typing comments is laggy, etc.

Now, we're also speaking subjectively here, so I've uploaded a video that records the performance issue on my end. You can see what happens when I hold down paste, and so on.

I already attempted to rebuild the databases and delete the NCB files, but it doesn't make a difference. The thing is, the lag occurs in multiple projects, in similar situations.

Having looked at past VAX bugs, I noticed that there were former cases where certain template code would result in slow parsing.

Are there any debugging steps on my end that I could take to look into template or macro issues relating to VAX?
Go to Top of Page

thethirdhalf
Junior Member

16 Posts

Posted - Nov 05 2008 :  11:08:47 AM  Show Profile  Reply with Quote
I was contacted by support, but I thought I'd reproduce what I wrote to them here:

In that particular test, disabling Format after Paste makes pasting appear to occur as just as fast as having VAX totally disabled. So that seems to definitely be part of it.

With that said, typing is still slow in similar files. Scrolling still lags, etc. I disabled syntax highlighting, all the formatting options, and I still see some lag when writing out for loops, etc.

Perhaps there is some common operation performed that the Format after Paste might help isolate? Because that helps a lot when pasting. No lag at all anymore.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000