-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loop_executor should block on it's work_queue instead of polling #117
Comments
Oberon00
changed the title
loop_executor should block on it's queue instead of polling
loop_executor should block on it's work_queue instead of polling
Feb 27, 2017
Le 27/02/2017 à 19:42, Christian N. a écrit :
|loop_executor::loop| is currently:
void loop()
{
while (!closed())
{
schedule_one_or_yield();
}
while (try_executing_one())
{
}
}
The first loop repeatedly calls |schedule_one_or_yield()| which is simply
void schedule_one_or_yield()
{
if ( !try_executing_one())
{
this_thread::yield();
}
}
The current implementation uses unnecessary CPU cycles (esp. if all
other threads are idle) by busy waiting. As
|concurrent::sync_queue<work> work_queue| already supports a blocking
|wait_pull_front| , it would be better to use a (private?)
|wait_executing_one| that behaves just like |try_executing_one| but
calls |work_queue.wait_pull_front| instead of |try_pull_front|.
IMHO, the current implementation is an outright performance bug.
Hi,
you are surely right.
Would you mind to add a github issue?
What about adding a pull request PR?
Vicente
|
Sorry. I didn't saw this was already a github issue. |
Ok, will do (but not before tomorrow). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
loop_executor::loop
is currently:The first loop repeatedly calls
schedule_one_or_yield()
which is simplyThe current implementation uses unnecessary CPU cycles (esp. if all other threads are idle) by busy waiting. As
concurrent::sync_queue<work> work_queue
already supports a blockingwait_pull_front
, it would be better to use a (private?)wait_executing_one
that behaves just liketry_executing_one
but callswork_queue.wait_pull_front
instead oftry_pull_front
.IMHO, the current implementation is an outright performance bug.
The text was updated successfully, but these errors were encountered: