-
Notifications
You must be signed in to change notification settings - Fork 194
Make resuming a continuation more efficient #1765
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
@vouillon, I looked at updating the runtime but I'm not familiar enough with this part. |
cf30bbf
to
93c0a04
Compare
I've finally managed to find my way out int the runtime. |
ab3e6a5
to
80dcdff
Compare
@vouillon, I've reworked the implementation of effects in the js runtime so that it looks more like what's done upstream in the c runtime. Can you take a look ? |
The deep_state benchmark (included in this PR in compiler/tests-jsoo/lib-effects/deep_state.ml) runs significantly faster with this PR $ hyperfine -L v before,after --warmup 3 'node {v}.js 64 500_000' Benchmark 1: node before.js 64 500_000 Time (mean ± σ): 2.745 s ± 0.046 s [User: 2.779 s, System: 0.036 s] Range (min … max): 2.671 s … 2.822 s 10 runs Benchmark 2: node after.js 64 500_000 Time (mean ± σ): 1.724 s ± 0.044 s [User: 1.761 s, System: 0.033 s] Range (min … max): 1.639 s … 1.771 s 10 runs Summary node after.js 64 500_000 ran 1.59 ± 0.05 times faster than node before.js 64 500_000 $ hyperfine -L v before,after --warmup 3 'node {v}.js 128 500_000' Benchmark 1: node before.js 128 500_000 Time (mean ± σ): 5.348 s ± 0.096 s [User: 5.386 s, System: 0.041 s] Range (min … max): 5.225 s … 5.473 s 10 runs Benchmark 2: node after.js 128 500_000 Time (mean ± σ): 3.636 s ± 0.247 s [User: 3.691 s, System: 0.042 s] Range (min … max): 2.986 s … 3.845 s 10 runs Summary node after.js 128 500_000 ran 1.47 ± 0.10 times faster than node before.js 128 500_000 |
The latest commit (that implement perform and reperform separately) is even faster. $ hyperfine -L v before,next --warmup 3 'node {v}.js 128 500_000' Benchmark 1: node before.js 128 500_000 Time (mean ± σ): 5.249 s ± 0.128 s [User: 5.290 s, System: 0.045 s] Range (min … max): 5.117 s … 5.468 s 10 runs Benchmark 2: node next.js 128 500_000 Time (mean ± σ): 2.383 s ± 0.043 s [User: 2.448 s, System: 0.040 s] Range (min … max): 2.286 s … 2.437 s 10 runs Summary node next.js 128 500_000 ran 2.20 ± 0.07 times faster than node before.js 128 500_000 |
@vouillon, thanks for the review. I've applied you suggestion and removed the caml_fiber_stack to only keep |
@vouillon, should we merge in the current state or should we wait for the wasm runtime? |
I would really prefer that #1461 get merged first, rather than asking @OlivierNicole to rebase it once more. |
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.
Copilot reviewed 4 out of 13 changed files in this pull request and generated no comments.
Files not reviewed (9)
- compiler/lib/effects.ml: Language not supported
- compiler/lib/parse_bytecode.ml: Language not supported
- compiler/tests-check-prim/main.4.14.output: Language not supported
- compiler/tests-check-prim/unix-Unix.4.14.output: Language not supported
- compiler/tests-check-prim/unix-Win32.4.14.output: Language not supported
- compiler/tests-jsoo/lib-effects/deep_state.ml: Language not supported
- compiler/tests-jsoo/lib-effects/dune: Language not supported
- runtime/wasm/effect.wat: Language not supported
- compiler/tests-full/stdlib.cma.expected.js: Evaluated as low risk
Comments suppressed due to low confidence (4)
runtime/js/effect.js:87
- The condition 'if (last === 0)' should be checked to ensure that 'last' is correctly initialized.
if (last === 0) {
runtime/js/effect.js:139
- [nitpick] The variable name 'last_fiber' is ambiguous. It should be renamed to something more descriptive, such as 'current_fiber'.
var last_fiber = caml_current_stack;
runtime/js/effect.js:132
- The new behavior introduced in the 'caml_perform_effect' function should be covered by tests.
function caml_perform_effect(eff, k0) {
runtime/js/effect.js:156
- The new behavior introduced in the 'caml_reperform_effect' function should be covered by tests.
function caml_reperform_effect(eff, cont, last, k0) {
CHANGES: ## Features/Changes * Compiler/Runtime: Make resuming a continuation more efficient in js (ocsigen/js_of_ocaml#1765) * Compiler/Runtime: Effects: add an optional feature of "dynamic switching" between CPS and direct style, resulting in better performance when no effect handler is installed * Compiler: Merged Wasm_of_ocaml (ocsigen/js_of_ocaml#1724) * Lib: fix the type of some DOM properties and methods (ocsigen/js_of_ocaml#1747) * Lib: removed no longer relevant Js.optdef type annotations (ocsigen/js_of_ocaml#1769) * Lib: Add other textMetrics property (ocsigen/js_of_ocaml#1784) * Lib: rename Firebug to Console (ocsigen/js_of_ocaml#1802) * Test: use dune test stanzas (ocsigen/js_of_ocaml#1631) * Test: run wasm tests on windows * Misc: drop support for IE * Misc: move tests to OCaml 5.3 * Misc: import many test from the OCaml codebase * Runtime: support for float16 bigarrays * Runtime: support more Unix functions (ocsigen/js_of_ocaml#1823) * Runtime: various filesystem fixes (ocsigen/js_of_ocaml#1825) ## Bug fixes * Compiler: Fix small bug in global data flow analysis (ocsigen/js_of_ocaml#1768) * Runtime: no longer leak channels * Runtime: Fix Marshal.to_buffer (ocsigen/js_of_ocaml#1798) * Runtime: unmarshalling objects should refresh its id * Runtime: check size upper bound during array creation * Runtime: return sys_error when reading from a closed channels * Runtime: fix parsing of hex-float with very large exponent * Runtime: make sure [n / 0L] is not optimized away by DCE * Runtime: fix Unix.LargeFile.stat/lstat * Runtime: fix stat/lstat times * Runtime: fix reading from stdin in an interactive nodejs
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
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
This was done in #1765 for the JavaScript runtime. See corresponding OCaml PR ocaml/ocaml#12735
Fix #1658
See corresponding OCaml PR ocaml/ocaml#12735