GeezerVison is showing github.com — src: move package_json_reader cache to c++ by anonrig · Pull Request #50322 · nodejs/node
Conversation
anonrig
commented
Oct 21, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Co-authored by @lemire
Local Benchmark
My local benchmarks says that running vite --version is 5% faster
❯ hyperfine 'node ../sveltejs-realworld/node_modules/vite/dist/node/cli.js --version' 'out/Release/node ../sveltejs-realworld/node_modules/vite/dist/node/cli.js --version' -w 10
Benchmark 1: node ../sveltejs-realworld/node_modules/vite/dist/node/cli.js --version
Time (mean ± σ): 101.4 ms ± 0.6 ms [User: 96.6 ms, System: 10.8 ms]
Range (min … max): 100.3 ms … 102.5 ms 28 runs
Benchmark 2: out/Release/node ../sveltejs-realworld/node_modules/vite/dist/node/cli.js --version
Time (mean ± σ): 96.3 ms ± 0.5 ms [User: 90.9 ms, System: 10.1 ms]
Range (min … max): 95.6 ms … 98.1 ms 30 runs
Summary
out/Release/node ../sveltejs-realworld/node_modules/vite/dist/node/cli.js --version ran
1.05 ± 0.01 times faster than node ../sveltejs-realworld/node_modules/vite/dist/node/cli.js --version
TODOs
- Move modules functionality to
node_modules.cc
- Move caching of package_json_reader to C++
- Make
node_modules.cc snapshottable
- Update run_main.js to just avoid constructing the whole object for the entry point.
- We could even call containsModuleSyntax from C++
- Move
getPackageScopeConfig from package_config.js to C++ side, and cache it on node_modules.cc
- Replace all packageJSONReader calls that looks for specific attribute to have equivalent C++ functions
- Investigate if imports & exports JSONParse needs to be cached on JS
Caveats
ERR_INVALID_PACKAGE_CONFIG does not include JSON.Parse() error message anymore. This mainly because we're using simdjson to avoid JS allocation while parsing for performance reasons.
- exports/imports without string, array or object value will now throw
ERR_INVALID_PACKAGE_CONFIG instead of returning an invalid value.
Benchmarks
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
JakobJingleheimer, Mike-Dax, lachlancollins, munepom, and ronjouch reacted with hooray emoji
bricss, alvarlagerlof, theoludwig, ChristoPy, CanadaHonk, twlite, JerrysShan, RomainLanz, Thanaen, shrujalshah28, and 7 more reacted with eyes emoji
All reactions
-
🎉
5 reactions
-
👀
17 reactions
|
Review requested:
- @nodejs/gyp
- @nodejs/loaders
- @nodejs/startup
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
added
c++
Issues and PRs that require attention from people who are familiar with C++.
lib / src
Issues and PRs involving general changes in the lib/ or src/ directories.
needs-ci
PRs that need a full CI run.
labels
Oct 21, 2023
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Adding dont-land labels again.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The mentioned issue is fixed in #50965
|
lemire reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Applying
semver-minor
PRs that contain new features and should be released in the next minor version.
because we're adding a new dependency to Node.js (0dd53da)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@anonrig I would like to land this on v20 but its not landing cleanly, can you backport?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced May 1, 2024
This was referenced Jun 17, 2024
This was referenced Oct 29, 2024
|
@anonrig this seems to cause a major performance regression. I did not look deeper into this but it's causing test code to run about 10x slower when running the following example code: DataDog/dd-trace-js#5360
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
anonrig
commented
May 2, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
@anonrig this seems to cause a major performance regression. I did not look deeper into this but it's causing test code to run about 10x slower when running the following example code: DataDog/dd-trace-js#5360
@BridgeAR Happy to take a look. Can you share a reproduction that doesn't require any external knowledge, and open a new issue and tag me?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I can't look into it closer at the moment. Since about 80% of all time is taken in Node.js when running the example, I guess it should be fine to check the source code to cause the problem.
It is actually just a redirected issue report, due to originally being reported in aws/aws-cdk#33576.
I'll open a issue about it though.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Sep 8, 2025
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
c++
Issues and PRs that require attention from people who are familiar with C++.
commit-queue-rebase
PRs the Commit Queue should land as multiple self-contained commits.
lib / src
Issues and PRs involving general changes in the lib/ or src/ directories.
needs-ci
PRs that need a full CI run.
notable-change
PRs with changes that should be highlighted in changelogs.
semver-minor
PRs that contain new features and should be released in the next minor version.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|