[Vm-dev] Use less CPU (improve battery life or reduce cost in the cloud)

Holger Freyther holger at freyther.de
Fri Sep 8 16:24:44 UTC 2017

> On 6. Sep 2017, at 05:45, John McIntosh <johnmci at smalltalkconsulting.com> wrote:


> self relinquishProcessorForMicroseconds: 1000
> In ioRelinquishProcessorForMicroseconds it would call getNextWakeupUsecs() to get the time when the next Process had to wake up. This always would be the Morphic event loop. In Cuis Smalltalk this could be as much as 20 seconds btw. 

I think Squeak and Pharo should increase the timeout parameter for the relinquish primitive as well (or as proposed by Bert a new primitive to go to sleep)

> sqInt
> ioRelinquishProcessorForMicroseconds(sqInt microSeconds)
> {

>     else {
>         realTimeToWait = nextWakeupUsecs - utcNow;
> 		if (realTimeToWait < microSeconds)  // so wait 1000 microseconds or longer not just 1000 microseconds 
> 			realTimeToWait = microSeconds;

So this is:

	timeToWait = MAX(MicroSecondsToNextDelayTimeout, microSeconds)

and it means we will sleep longer than when the next delay is due? This might be the reason the system is consuming less CPU? Do I understand this correctly?

> I'm sure I changed the Mac VM to signal the event semaphore on pending events about 15 years ago.

Yes it does signal the semaphore but it seems that it requires the event loop to be "pumped" periodically? Can you confirm it? Is there a way to get a fd for the event loop?

More information about the Vm-dev mailing list