coio-rs icon indicating copy to clipboard operation
coio-rs copied to clipboard

Improve processor parking strategy

Open zonyitoo opened this issue 8 years ago • 3 comments

Right now Processors will wait forever in its own channel until got notified by ProcMessage. So it won't try to steal jobs from the other Processors!

So we have to add something to achieve:

  1. Processor won't spin itself when it has nothing to do.
  2. Processor can process the ProcMessages in time.
  3. Processor can steal jobs from the other Processors.

Please add comments below :)

zonyitoo avatar Jan 30 '16 03:01 zonyitoo

We might want to thread::park()/unpark() the current thread and add it's handle to a processor wait list on the Scheduler...

This thread would get unparked whenever Scheduler::ready() is called with a preferred_processor which is the currently parked processor, or when a Processor determines that it has a big amount (>N) of coroutines in it's deque and would like to have some help by another Processor.

Well something like that I guess should solve this... But I'm quite sure that the Processors have to have a certain level of "cooperation".

lhecker avatar Jan 30 '16 09:01 lhecker

But every time the ready() is called, you would have to check the parked list and wake one thread up. Please try to implement it and do a simple benchmarking on it.

zonyitoo avatar Jan 30 '16 10:01 zonyitoo

Ah, I accidentally merged this branch to master by hand. My fault. We could keep on discussing in the issue.

zonyitoo avatar Jan 30 '16 18:01 zonyitoo