[squeak-dev] DelayIdleScheduler experiment

Ben Coman btc at openinworld.com
Sun Oct 7 08:11:13 UTC 2018

Cross posting since at this level systems are still very similar.

I've sometimes wondered about how the idle process
relinquishing the CPU interacted with delay scheduling,
since they operate at the extreme opposite ends of process priorities.

Historically there was...
ProcessorScheduler class >> idleProcess
[    "A default background process which is invisible."
     [true] whileTrue:
         [self relinquishProcessorForMicroseconds: 1000]

which had the following performance this for later comparison...
    (1 to: 10) collect: [:i | [ (Delay forMilliseconds: 1) wait ] timeToRun
    ==> "#(2 5 4 2 4 4 2 4 4 3)"

To improve battery life yield time Pharo changed this to 50000 in...
* https://github.com/pharo-project/pharo/commit/0b0d12dc
but had a negative impact on delays...
    (1 to: 10) collect: [:i | [ (Delay forMilliseconds: 1) wait ] timeToRun
   ==> "#(36 51 50 51 50 51 51 30 50 50)"
as reported...

The problem seems to be that #relinquishProcessorForMicroseconds: suspends
the main VM thread for a fixed amount during which expired delays cannot be
dealt with.  I'm not sure of the exact mechanism in the VM but this looks

I'm not sure about Linux

One idea was to have a setting, but another path is to mix the
into the delay-scheduling to dynamically relinquish up to exactly when the
activeDelay expires.

After loading...
you can do...
    DelayIdleTicker installExperiment.
    (1 to: 10) collect: [:i | [ (Delay forMilliseconds: 1) wait ] timeToRun
==>"#(1 1 2 2 2 2 2 2 2 2)" which btw is half the latency of the original
    DelayIdleTicker debug: true.  "CPU usage goes way up"
    DelayIdleTicker uninstall.

I'm now seeking:
* comment on how this might interact with parts of the VM I'm not familiar
* help to discover and stress test corner cases.
* help to determine if there actually is a benefit and characterize what
that is,
especially anyone familiar with headless images with reduced UI and I/O
I was surprised to see the existing system already often showed 0% CPU
usage (in Windows).

cheers -ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20181007/6514df55/attachment.html>

More information about the Squeak-dev mailing list