DelayIdleScheduler experiment
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 asMilliSeconds]. ==> "#(2 5 4 2 4 4 2 4 4 3)" To improve battery life yield time Pharo changed this to 50000 in... * https://pharo.fogbugz.com/f/cases/20425/Yield-longer-in-ProcessorScheduler-i... * 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 asMilliSeconds]. ==> "#(36 51 50 51 50 51 51 30 50 50)" as reported... https://pharo.fogbugz.com/f/cases/22400/Delays-are-not-working-properly 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 related... Win: https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/e2fa2d1/platforms/win... Mac: https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/a8a1dc1/platforms/uni... I'm not sure about Linux One idea was to have a setting, but another path is to mix the idle-relinquish into the delay-scheduling to dynamically relinquish up to exactly when the activeDelay expires. After loading... https://github.com/pharo-project/pharo/pull/1887 you can do... DelayIdleTicker installExperiment. (1 to: 10) collect: [:i | [ (Delay forMilliseconds: 1) wait ] timeToRun asMilliSeconds]. ==>"#(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 with. * 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 events. I was surprised to see the existing system already often showed 0% CPU usage (in Windows). cheers -ben
participants (1)
-
Ben Coman