-
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
tools: refactor js2c.cc to use c++20 #54849
Conversation
7be9917
to
de21f61
Compare
@anonrig Let me check. |
@anonrig Please see anonrig#14 |
…ed at compile time
amazing work as always @lemire |
Co-authored-by: Daniel Lemire <[email protected]>
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.
Generally LGTM with nits.
Co-authored-by: Daniel Lemire <[email protected]>
@anonrig I did not lint my changes. :-) |
@lemire it seems windows build is failing. any idea? |
"An identifier exceeds the length of the internal buffer used for identifiers. Shorten the name." That's a new one for me. I don't know if this is actually the failure but spotted it in the build log. |
I did not try with Visual Studio (yet), but here is the node_javascript.cc file generated on my mac with this PR: https://gist.github.com/lemire/a8544683cb6fba911a86843cff048e0d By the look of it, we have a string... a gigantic string spanning thousands of lines. I think that's what Visual Studio does not like, but how (or whether) it relates to this PR, I don't know. |
Ok. I think I figured it out. |
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.
Please don't merge this yet, I think we can make the table faster.
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.
Nevermind, it is fine.
@joyeecheung any concerns with landing this? |
The starts_with/ends_with changes LGTM. For the code table changes, I think it's a bit over-engineering to make the otherwise straigt-forward code this convoluted to save ~40MB for a build that already takes more than 4GB of memory to work (some of the digital oceans machines with 4GB memory and no extra swap space failed a few weeks ago because of this - which happened during building V8 and would not be in parallel to js2c), or to shave off a few ms from a build that takes tens of minutes/hours. But it's not that convoluted currently for me so I am fine with it (#54849 (comment) on the other hand, is definitely over-engineering this IMO). I would not block it but I don't feel like approving the code-table part either though because I don't see it as an improvement - If it was another way around, say the code was written like this originally and someone sent a PR to simplify it to the current |
Just to clarify... the current change with respect to the table is optimized for speed, not memory usage. If we want to reduce memory usage, we can drop the table and call I expect that compared with @joyeecheung's port of this code from JavaScript to C++, this PR won't move the needle performance wise. But it should be a tiny bit faster!!! 💨 |
FWIW the primary motivation of the original port (from Python, not JavaScript) was to experiment with compression options other than zlib (zlib had been shown to be too slow in decompression that we reverted snapshot compression to reverse a runtime performance regression). The performance aspect was only a nice-to-have (also here C++ is at least easier to get reviews from compared to Python). |
Co-authored-by: Daniel Lemire <[email protected]>
Co-authored-by: Daniel Lemire <[email protected]>
Co-authored-by: Daniel Lemire <[email protected]>
Commit Queue failed- Loading data for nodejs/node/pull/54849 ✔ Done loading data for nodejs/node/pull/54849 ----------------------------------- PR info ------------------------------------ Title tools: refactor js2c.cc to use c++20 (#54849) Author Yagiz Nizipli <[email protected]> (@anonrig) Branch anonrig:tools-simplify -> nodejs:main Labels c++, tools, commit-queue-squash, dont-land-on-v18.x, dont-land-on-v20.x Commits 12 - tools: refactor js2c.cc to use c++20 - reducing memory usage and making GetCode's buffer potentially evaluat… - Update js2c.cc - Update js2c.cc - lint - minor fix - Update tools/js2c.cc - removing constexpr - lint - Update tools/js2c.cc - Update tools/js2c.cc - Update tools/js2c.cc Committers 3 - Yagiz Nizipli <[email protected]> - GitHub <[email protected]> - Daniel Lemire <[email protected]> PR-URL: https://github.com/nodejs/node/pull/54849 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/54849 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last approving review: ⚠ - Update tools/js2c.cc ⚠ - Update tools/js2c.cc ⚠ - Update tools/js2c.cc ℹ This PR was created on Sun, 08 Sep 2024 16:08:34 GMT ✔ Approvals: 2 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/54849#pullrequestreview-2288589793 ✔ - Daniel Lemire (@lemire): https://github.com/nodejs/node/pull/54849#pullrequestreview-2297353318 ✔ Last GitHub CI successful ℹ Green GitHub CI is sufficient -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/10894139953 |
Landed in cde6dcc |
PR-URL: #54849 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
PR-URL: nodejs#54849 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
PR-URL: nodejs#54849 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Lemire <[email protected]>
Refactors js2c.cc to use modern syntax.