-
Notifications
You must be signed in to change notification settings - Fork 194
Wasm runtime: make resuming continuations more efficient #1892
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
Conversation
@OlivierNicole, Would you be able to review this PR ? |
I used the deep_state benchmarks and show the following improvement compile the bench with:
before:
after:
stack switching is however very slow
|
Yes, that's expected. It goes through the JavaScript event loop for each stack switch. |
Should the doc/readme say something about this ? |
We have this at the moment: js_of_ocaml/manual/wasm_overview.wiki Line 56 in 55c6228
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review the wat diff but the CI is happy. @vouillon, I'll let you decide whether to merge now or wait for more review
I am swamped for now, but maybe I can start on Friday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a high level point of view, I’m not sure to understand why this change affects %perform
and %reperform
, while ocaml/ocaml#12735 only affected %resume
. There was also code shared between perform and reperform (in line with the native and bytecode backends) that this PR seems to remove, and I’m not sure to understand why.
I’m happy to review this PR but I reiterate that to do that I would need a high-level description of the change, otherwise I don’t have enough context, and figuring it out by myself is going to take forever. Visibly ocaml/ocaml#12735 is not the whole story. |
You can have a look at #1765 and #1891. We have some changes to make in perform/reperform since we were storing the fibers in reversed order in the continuation. They were already stored in the right order in the OCaml runtime. Also, we need to store the tail of the stack in the continuation. Separating perform and reperform also allows some simplifications regarding unhandled effects: for perform, we can just raise the exception right away, and for reperform, we can resume the continuation with an exception. One no longer needs to put a default handler at the top of the current stack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me.
Do we have an effects benchmark to assess the impact of this PR?
|
Oh, sorry, I had scanned through this message but for some reason thought it was on the other PR (the Javascript runtime one). |
This was done in #1765 for the JavaScript runtime. See corresponding OCaml PR ocaml/ocaml#12735
This was done in #1765 for the JavaScript runtime.
See corresponding OCaml PR ocaml/ocaml#12735
fix #1779