-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Enable Maglev #50690
Comments
I ran a random subset of 82 benchmark files from the repo, once with maglev and once without. Overall the results from this sample look positive for Maglev, of the "statistically significant" changes:
Here are the raw CSVs from |
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: nodejs#50690
It seems the positive ones are mostly microbenchmarks that probably are not written in a way to eliminate compilation speed out of the measurement. So if it's Maglev kicking in instead of Turbofan, that might make a difference in a micro-benchmarking loop, but then in real world applications users don't usually run one API in a loop so that when or which compiler kicks in makes a significant difference. We should probably look into some more real-world CLIs for the measurement (e.g. #50684), where a mid-tier optimizing compiler could make a meaningful difference (A significant part of CLI startup is compilation. At the same time, Node.js core could also hit many hot paths trying to complete the loading process). |
Can you show where it's enabled in Chrome's build config? |
I don't know enough about Chrome's setup to answer that precisely. You can run Chrome with Lines 505 to 508 in fc2862b
|
I tried the startup benchmarks in that PR and there wasn't a significant difference with Maglev on/off unfortunately. I guess what we need here is more information on "for each benchmark, which compilation tier does it end up in?" It is possible that some of them never reach Turbofan at all. We could a detailed analysis like this one, but it sounds like you think it would be better to try to find representative macro-benchmarks rather than continuing to look at the microbenchmarks. |
On a small Typescript build job, it looks like --maglev is ~7-10% faster than --no-maglev:
I can't share the repo unfortunately, but will try to run typescript on some public repos to see if it generalizes. |
Trying more Typescript projects. I chose xstate which is one the libraries that Typescript benchmarks for performance regressions against. I compiled node with v8-lkgr. $ git clone https://github.com/statelyai/xstate.git
$ yarn install and then I timed a typecheck after a clean:
10 iterations of
10 iterations of --no-maglev:
20% improvement in wall-clock and 14% improvement in CPU-time. |
OK. I'm fine with the proposal as long as we enable it by default on the same architectures as V8. |
Sure. Do you have an opinion on whether enabling it by default can happen in a minor release or if that should be a semver-major change? |
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: #50690 PR-URL: #50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
Another benchmark: eslint on specific directories of the Node.js codebase. Overall marginally (i.e. 2-4%) faster with maglev than without: $ hyperfine -L maglev --maglev,--no-maglev './node_maglev {maglev} tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives lib'
Benchmark 1: ./node_maglev --maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives lib
Time (mean ± σ): 12.885 s ± 0.271 s [User: 17.605 s, System: 0.775 s]
Range (min … max): 12.578 s … 13.384 s 10 runs
Benchmark 2: ./node_maglev --no-maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives lib
Time (mean ± σ): 13.105 s ± 0.349 s [User: 18.707 s, System: 0.688 s]
Range (min … max): 12.762 s … 13.838 s 10 runs
Summary
'./node_maglev --maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives lib' ran
1.02 ± 0.03 times faster than './node_maglev --no-maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives lib'
$ hyperfine -L maglev --maglev,--no-maglev './node_maglev {maglev} tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives benchmark'
Benchmark 1: ./node_maglev --maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives benchmark
Time (mean ± σ): 3.792 s ± 0.050 s [User: 5.603 s, System: 0.351 s]
Range (min … max): 3.716 s … 3.891 s 10 runs
Benchmark 2: ./node_maglev --no-maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives benchmark
Time (mean ± σ): 3.943 s ± 0.061 s [User: 5.899 s, System: 0.297 s]
Range (min … max): 3.877 s … 4.055 s 10 runs
Summary
'./node_maglev --maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives benchmark' ran
1.04 ± 0.02 times faster than './node_maglev --no-maglev tools/node_modules/eslint/bin/eslint.js --max-warnings=0 --report-unused-disable-directives benchmark' |
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: #50690 PR-URL: #50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: nodejs#50690 PR-URL: nodejs#50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: nodejs#50690 PR-URL: nodejs#50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: #50690 PR-URL: #50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: #50690 PR-URL: #50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
The middle-tier compiler definitely has a positive impact on JS development tools(CLI apps). |
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: #50690 PR-URL: #50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
This allows Maglev (see ref) to build on the compilers we use. Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 Refs: nodejs#50690
This adds a configuration flag to enable V8's Maglev compiler. Unfortunately compilation fails unless you have clang-14+ or gcc-13+, but I sent a patch for that upstream. Other than that, it builds and all tests pass locally on my x86-64 Linux machine. The gn scraper regexes were broken preventing the compilation from linking. Fix them. As a drive-by, also add additional conditionals for compilation on 32-bit arm. Refs: #50690 PR-URL: #50692 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
This allows Maglev (see ref) to build on the compilers we use. Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 Refs: nodejs#50690
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: #51200 Refs: #50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: nodejs#51200 Refs: nodejs#50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: nodejs#51200 Refs: nodejs#50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: nodejs#51200 Refs: nodejs#50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: nodejs#51200 Refs: nodejs#50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: #51200 Refs: #50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Enable V8's new maglev compiler by default on supported architectures. This brings modest performance improvements for short-lived workloads like CLI programs (see the linked issue) and brings Node.js's configuration slightly closer to Google Chrome's. I marked this change as semver-major because Maglev can theoretically cause performance regressions, although I haven't seen an example of that in the (somewhat limited) benchmarking I've done. **Notable Change Summary:** V8's Maglev Compiler is now enabled by default on supported architectures (https://v8.dev/blog/maglev). Maglev improves CPU performance for short-lived CLI programs by around 8%. Fixes: nodejs#50690
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: #51200 Refs: #50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> PR-URL: #50115 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Enable V8's new maglev compiler by default on supported architectures. This brings modest performance improvements for short-lived workloads like CLI programs (see the linked issue) and brings Node.js's configuration slightly closer to Google Chrome's. I marked this change as semver-major because Maglev can theoretically cause performance regressions, although I haven't seen an example of that in the (somewhat limited) benchmarking I've done. **Notable Change Summary:** V8's Maglev Compiler is now enabled by default on supported architectures (https://v8.dev/blog/maglev). Maglev improves CPU performance for short-lived CLI programs by around 8%. Fixes: #50690 PR-URL: #51360 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
Enable V8's new maglev compiler by default on supported architectures. This brings modest performance improvements for short-lived workloads like CLI programs (see the linked issue) and brings Node.js's configuration slightly closer to Google Chrome's. I marked this change as semver-major because Maglev can theoretically cause performance regressions, although I haven't seen an example of that in the (somewhat limited) benchmarking I've done. **Notable Change Summary:** V8's Maglev Compiler is now enabled by default on supported architectures (https://v8.dev/blog/maglev). Maglev improves CPU performance for short-lived CLI programs by around 8%. Fixes: nodejs#50690 PR-URL: nodejs#51360 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: nodejs#51200 Refs: nodejs#50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> PR-URL: nodejs#50115 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Enable V8's new maglev compiler by default on supported architectures. This brings modest performance improvements for short-lived workloads like CLI programs (see the linked issue) and brings Node.js's configuration slightly closer to Google Chrome's. I marked this change as semver-major because Maglev can theoretically cause performance regressions, although I haven't seen an example of that in the (somewhat limited) benchmarking I've done. **Notable Change Summary:** V8's Maglev Compiler is now enabled by default on supported architectures (https://v8.dev/blog/maglev). Maglev improves CPU performance for short-lived CLI programs by around 8%. Fixes: nodejs#50690 PR-URL: nodejs#51360 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
Original commit message: [maglev] fix non-ptr-compr compilation on old compilers When pointer compression is disabled, the preprocessor expands some static asserts to static_assert(false), which doesn't compile on compilers not implementing the C++ defect report CWG2518, notably clang before version 17 and gcc before version 13. Adding in part of the template parameter to the static assert prevents it from being evaluated immediately which fixes the compilation. Test: compiled with gcc-11 and clang-14 without pointer compression. Change-Id: I95ce29bdb1278e6dad9e592d6f9476395f8aeb59 Fixed: v8:14355 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5022760 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#91553} Refs: v8/v8@de611e6 PR-URL: #51200 Refs: #50690 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
What is the problem this feature will solve?
V8 recently introduced their new Maglev compiler which is a mid-tier compiler (blog post, design doc).
We currently do not compile or ship Maglev.
What is the feature you are proposing to solve the problem?
Build and enable Maglev. Proposed plan:
Open questions
What alternatives have you considered?
We could also not enable Maglev, which is a valid choice.
Pros of shipping:
Cons of shipping:
--no-maglev
but it may be difficult to figure out that Maglev is causing the regression.The text was updated successfully, but these errors were encountered: