Closed zevv closed 4 years ago
"Don't do that" is the proper answer, right? :)
Thanks for your talk today, and it was a pleasure meeting you!
Here is a way to do that:
import weave, os
init(Weave)
syncRoot(Weave) # Empty the task queue
echo "Going to sleep"
os.sleep(10 * 1000)
echo "Waking up"
exit(Weave)
In your case what happens is:
In short, similar to async/io don't block without handing back control to the scheduler otherwise mayhem ensues.
Unfortunately this is not solvable with Weave message-passing design. It would work if thefts were shared memory based, sleeping threads would not prevent active threads from looking in their deques but this tradeoff also prevents many optimizations.
Alternatively I could change the backoff mechanism to have regular "maintenance" wakeups (for example exponential backoff) bu it's less efficient on a single computer (though it's the only way to have backoff in a distributed setting https://github.com/mratsim/weave/blob/v0.3.0/weave/channels/event_notifiers_and_backoff.md#distributed-backoff-and-contention-resolution-strategies
Running the following snippet makes my laptop hot, all CPUs spin at 100%
Quick profiling indicates that CPU is spent in
tryRecv
/recvProxy