Replies: 5 comments 1 reply
|
Have you benchmarked the performace? cc: @George-Miao |
|
I have not yet benchmarked it. I shall get back with the results. |
|
I was trying to recreate a scenario which reflects what the change is trying to optimize for. The change that i made requires the Happy to be corrected if I am missing something. |
|
Well, that's not really possible to happen since there will be only one JoinHandle, which is not cloneable. There's only one writer exist in the first place. SETTING_WAKER flag is only used by executor to avoid waking the waker when it's finished or cancelled. |
|
But still, thanks a lot for all the effort trying to optimize the executor! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The implementation of the
pollmethod forRemotechecks whether the currentwakerneeds to be updated usingwill_wakeand callsState::start_setting_wakeronly if it is required. If yes, it then checks whether awakerwas inserted in that window and drops it unconditionally. We could insert another check usingwill_wakeon thatwakeras if it returnstrue, we could avoid two atomic operations as in one for the increment of the ref-count while cloning thewakerand another when thewakergets dropped. Further, even if the setting ofwakerin the window is highly unlikely, the branch predictor will end up being right most of the times.I tried to change it from
to the following snippet
If this is worth adding, would be happy to make a PR :)
All reactions