Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Backoff not kicking in, 100% usage on all CPUs #103
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