Re: 99% CPU usage in CWinThread::PumpMessage

From: Olaf van der Spek (Olaf_at_XCC.TMFWeb.NL)
Date: 04/12/04


Date: Mon, 12 Apr 2004 17:48:42 +0200

KS wrote:
> Not sure without seeing the code.

If I understand the profiler output correctly, the following lines tell
me that the PumpMessage function consumed 98.6% of the time itself and
99.1% of the time was consumed by itself and it's children.
>> 75351,273 98,6 75773,696 99,1 1437
>>CWinThread::PumpMessage(void) (mfc42d.dll)

> But if you have a thread that has a loop in it, I'd suggest putting a
> Sleep(100) inside the loop. I've had problems with threads hogging up
> resources.

I do have a loop, but it's blocking on a select call.
>
> Another possibility is to lower the thread's priority.

That won't solve the CPU usage itself, although it's a reasonable
temporary workaround.
>
> KS
>
> "Olaf van der Spek" <Olaf@XCC.TMFWeb.NL> wrote in message
> news:u6f7utJIEHA.3444@TK2MSFTNGP11.phx.gbl...
>
>>Hi,
>>
>>I'm writing a file transfer application and I'm stuck with a nasty
>>issue. For some weird reason, CPU usage hits 99% some times. So I fired
>>up the VC6 profiler, the results are attached.
>>
>>98% of the time is spend inside CWinThread::PumpMessage
>>But that's a simple function, how can so much time be spend there?
>>
>>Profile: Function timing, sorted by time
>>Date: Sun Apr 11 21:12:13 2004
>>
>>
>>Program Statistics
>>------------------
>> Command line at 2004 Apr 11 20:57: "F:\VC\xbt\XBT Client\Debug\XBT
>>Client"
>> Total time: 76459,318 millisecond
>> Time outside of functions: 20,774 millisecond
>> Call depth: 36
>> Total functions: 3188
>> Total hits: 1435373
>> Function coverage: 39,6%
>> Overhead Calculated 2
>> Overhead Average 2
>>
>>Module Statistics for xbt client.exe
>>------------------------------------
>> Time in module: 76438,544 millisecond
>> Percent of time in module: 100,0%
>> Functions in module: 3188
>> Hits in module: 1435373
>> Module function coverage: 39,6%
>>
>> Func Func+Child Hit
>> Time % Time % Count Function
>>---------------------------------------------------------
>> 75351,273 98,6 75773,696 99,1 1437
>>CWinThread::PumpMessage(void) (mfc42d.dll)
>> 75,806 0,1 75,806 0,1 58546 operator delete(void *)
>>(mfc42d.dll)
>> 73,318 0,1 107,126 0,1 155186
>>std::allocator<bool>::destroy(bool *) (bt_file.obj)
>
>
>



Relevant Pages

  • Re: object system...
    ... but you shall not reason contradictory. ... while Halt loop ... Any finite halting problem is decidable, ...
    (comp.object)
  • Re: Which Is Better?
    ... The reason they gave was from a DBA perpspective like it was ... MERGE really necessary here - do you do any inserts in that loop, ... statistics for both approaches and compare them to see what could ... Did you capture any other statistics aside from run time ...
    (comp.databases.oracle.misc)
  • Re: measuring clock cycles per second
    ... In fact, I am not trying to convince you, I'm trying to find a reason why you would think it's useless. ... Let's assume that a program only executes a single loop and this loop ... Even if the average execution time of #1 is exactly 1/4 of the sampling interval and the average execution time of #2 is exactly 3/4 of the sampling interval, then, provided the standard deviation of the respective probability distributions of times is nonzero, the total time taken by the loop will, in general, be unequal to the sampling interval, even if by a mere 1%. ... Rather than the poor resolution, I find the fact that measurement itself leads to changes in timing more difficult to work with, especially when -g is used (not sure about the reason). ...
    (comp.os.linux.development.apps)
  • Re: Need Thread Advice
    ... The event object concept seems more reasonable. ... The code is written so that when a button is clicked, I open a com port ... but the release code hung in the whileloop. ... reason for this is volatile typically does not have the correct memory ...
    (microsoft.public.vc.mfc)
  • Re: Correct C++ tutorial part 3 "Intro to loops" available (Windows, mingw/msvc/std)
    ... >> see no reason told for this statement. ... Why would a floating point type misleading if I need a floating point value? ... do you need a floating point iteration or not? ... > loop control variables. ...
    (comp.lang.cpp)