trufflesqueak icon indicating copy to clipboard operation
trufflesqueak copied to clipboard

Higher-priority processes are not scheduled

Open LinqLover opened this issue 2 years ago • 5 comments

The following

[10 seconds busyWait] forkAt: 39.

blocks my entire image for 10 seconds, the UI process does not get scheduled before the busy wait is over. In the OSVM, this works, however.

Does the implementation of busyWait has a suspension point or is this accidental behavior of the OSVM? I could not find an official definition of suspension points, unfortunately ...

However, even if I modify #busyWait and insert a Processor yield inside the loop, the observed behavior does not change, so I guess something with the scheduler does not work as expected here.

LinqLover avatar May 26 '22 12:05 LinqLover

#busyWait uses [Time utcMicrosecondClock >= proceedTime] whileFalse, which is a block that includes primitive calls only. Therefore, this is a different form of the issue documented in https://github.com/hpi-swa/trufflesqueak/issues/104.

fniephaus avatar May 27 '22 20:05 fniephaus

But Processor yield didn't help, so isn't there something wrong with primitiveYield?

LinqLover avatar May 27 '22 20:05 LinqLover

But Processor yield didn't help, so isn't there something wrong with primitiveYield?

No, as you mentioned, Processor yield is a primitive calls as well so the loop body remains trivial in the sense that there is no actual send that would trigger a check for interrupts. As a consequence, TruffleSqueak's bytecode loop will not be interrupted until the loop is exited. In https://github.com/hpi-swa/trufflesqueak/commit/581730f9f927bdfee65fe67ee687f4cca68a4329, I drafted an idea that adds interrupt checks to the bytecode loop for such trivial loops. While this fixes both #167 and #104, we need to run the benchmarks to see how much it impacts peak performance.

fniephaus avatar May 27 '22 21:05 fniephaus

Maybe you are right though, not sure why primitiveYield doesn't resolve the problem. Looks like I may need to take another look at the primitive.

fniephaus avatar May 28 '22 12:05 fniephaus

Nope, my first comment was correct: you put the yield into busyWait and not into the block itself. Since the block contains no actual sends and no explicit yield, the bytecode loop is not exited until the timer expires. So indeed, we need to make sure to check for interrupts in such trivial loops.

fniephaus avatar May 29 '22 07:05 fniephaus