CPU consumption running Squeak as Windows service

John M McIntosh johnmci at smalltalkconsulting.com
Fri Sep 17 18:12:47 UTC 2004


It's most likely to do with how  
ioRelinquishProcessorForMicroseconds(int microSeconds) handles  
sleeping.
When there is no Smalltalk processes able to run, the UI is waiting for  
a UI event, all Delays are waiting to expire
and all the sockets are waiting on input the Smalltalk Scheduler  
schedules the lowest priority process which
asks this primitive to wait a few microseconds. This is somewhat bogus  
since we ask to sleep a few microseconds.

So a few years back I recommended altering things to wait until the  
first pending Delay finishes or
if a socket/ui event requires servicing, that would maximize sleep and  
I'd hope most mac  users would say their
Squeak VM uses under 10% when idle.  {Comments are welcome on this}

I'll explain how the os-x carbon one works, I can't comment on the  
windows code, but as you've seen it's not
sleeping as much as expected.

The os-x carbon code does:

    /* Wakeup interrupt processing once we return because there will be  
a pending interrupt we'll need to service */
    setInterruptCheckCounter(0);

    /* get the time now, and compare to the time we need to wake up if  
we have a pending Delay running.
   If there is not pending delay then we'll sleep 16 milliseconds. With  
MVC this was true, with Morphic this is never true.
   If the wakeup time in is the past, just return don't sleep */

    now = (ioMSecs() & 536870911);
     if (getNextWakeupTick() <= now)
         if (getNextWakeupTick() == 0)
             realTimeToWait = 16;
         else {
             return 0;
     }
     else
         realTimeToWait = getNextWakeupTick() - now;

    /* Call this unix async poll routine to nano-sleep until we exceed  
the time to wait,
	or if a user generated event or socket event occurs. This ensures we  
maximize sleeping, however
	morphic drives a UI poll event every 1/60 of a second, still we'll get  
only 6ish% CPU when idle... */

     aioPoll(realTimeToWait*1000);


If you have access to the windows C code and a desire to build your own  
VM then it may be possible to reduce the
CPU usage if you have a good understanding of the side-effects to  
making that change to ioRelinquishProcessorForMicroseconds.


On Sep 17, 2004, at 4:01 AM, Dmitrij Abolichin wrote:

> Hi,
> We have small app that runs on server and acts as kind of "task  
> runner".
>  Squeak is running as Windows service, and consumes 50% of CPU  
> resources. At that time Squeak CPUWatcher indicates, that "idle  
> process" consumes about 100%.
>  Can anybody explain why Squeak.exe takes so many CPU resources?
> VM version 3.6.2, Squeak ver. 3.6-5424
>  
>
>
--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list