-
Notifications
You must be signed in to change notification settings - Fork 26
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
Refresh context only after thread switch #520
Conversation
This commit fixes #434. It tries to keep the number of calls to pony_ctx to a minimum by only updating after a (potential) switch of threads, but then doing it "across the stack" by using a double pointer to a stack variable in the `run` function of the scheduler.
BTW, this PR runs |
@albertnetymk: since me and @kikofernandez wrote this, could you review it? |
I could only confirm 3%, but that's still better! |
You should not use the |
( vs.
( |
in my machine, using your same loop:
This suggests a speedup of 8.6% (53.83 / 49.53) |
Nice! |
I originally thought suspend, await and get all need to taken care of in order to do this double pointer trick, but apparently, they use the same code for context manipulation. The final ctx update in I was expecting clang to cache
I suggest using The call to |
I thought we removed that! Fixed now
We were expecting the same! Fixed as per your suggestion now.
Agreed. Fixed. |
I think this can be merged. Would do so in an hour if no objections. |
This commit tries to keep the number of calls to
pony_ctx
to a minimumby only updating it after a (potential) switch of threads, but then doing it
"across the stack" by using a pointer to a stack variable in the
run
function of the scheduler. Most functions have been changed to pass
around this double pointer to the context (rather than just a pointer), and
the most important line is line 236 of encore.c:
No other part of the code should need to write to
*ctx
.This commit fixes #434.