TabClientWnd using lots of CPU |
Post Reply |
Author | |
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
Posted: 11 January 2007 at 4:56pm |
I got a few complaints from some users of my software saying that on their Dual XEON dev machines, my product was using 15-20% of the CPU in total (across 4 processors) when they werent doing anything at all.
This figure went down slightly if they had only 1 doc open but went up significantly with lots of documents. After some testing, we found that if they turned off the client tabs option so they just had maximised child windows for each document it went down to 0%. It seems that the MDITabClientWnd is using a lot of CPU, have you noticed anything in this area and/or done any profiling on it? |
|
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
It looks like CXTPTabClientWnd::OnIdleUpdateCmdUI is calling UpdateContents which is quite a heavy function.
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
in issue https://forum.codejock.com/forum_posts.asp?TID=6027 you wrote that you added pFoundItem->SetImageIndex( pFoundItem->GetImageIndex() );
It will Recalculate layout each time OnIdleUpdateCmdUI called.
remove it.
Set breakpoint in CalcWindowRect and be sure it called if client size changed and not all time.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
Thank you, I hadnt got around to reversing my change on your code. So glad it was something simple ... thanks!
Wot great support, this could have been a nightmare to resolve if you hadnt remembered about my other change. Well done Oleg! |
|
Simon HB9DRV
Senior Member Joined: 07 July 2005 Location: Switzerland Status: Offline Points: 458 |
Post Options
Thanks(0)
|
Another thing to consider is CWinApp::IsIdleMessage - if you override this you can greatly reduce idle processing.
|
|
Simon HB9DRV
|
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1198 |
Post Options
Thanks(0)
|
Hi Simon;
I agree by 100%. In my case I had a MDI application with online trending document types. These documents used timers (WM_TIMER messages) posted by the individual MDI child frame windows to update their contents. These WM_TIMER messages increased the CPU usage due to excessive calls of OnIdleUpdate... .
After overriding the IsIdleMessage the CPU usage went down to 0% from up to 100% when more than 10 to 15 documents were open!
|
|
Martin
Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0 Platform: Windows 10 v 1909 (64bit) Language: VC++ 2017 |
|
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
What is this override used for then and what did you do, just return FALSE?
|
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1198 |
Post Options
Thanks(0)
|
Hi Dan;
This virtual function determines whether a message in the message queue is a message good for idle processing or not. If this function returns TRUE, the OnIdleUpdate... processing is done (OnUpdateCommandUI() handlers are called).
In the default implementation WM_TIMER messages are defined as 'idle' messages, resulting in OnUpdateCommandUI() calls.
In my application, each mdi child window has started its own timer and the timer interval is about 200ms. This means that after opening one window, the OnUpdateCommandUI() handlers are called 5 times per second. 10 open child frame windows lead to 50 calls to all OnUpdateCommandUI(). This uses lots of CPU!!!
So I wrote my own IsIdleMessage() to return also FALSE when WM_TIMER messages are handled.
|
|
Martin
Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0 Platform: Windows 10 v 1909 (64bit) Language: VC++ 2017 |
|
Simon HB9DRV
Senior Member Joined: 07 July 2005 Location: Switzerland Status: Offline Points: 458 |
Post Options
Thanks(0)
|
I had to ignore most of my registered messages. I have quite a few common controls in the toolbars and updating these is / was quite expensive. |
|
Simon HB9DRV
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |