GeezerVison is showing github.com — build,src,crypto: improve startup performance by avivkeller · Pull Request #65549 · nodejs/node
Conversation
avivkeller
commented
Aug 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
(I can split these into separate PRs if needed, but I figured a single PR with separate commits would be sufficient since the changes are related: ce94bb8 made me think about 2dffdbf, which in turn relied on a1ba046.)
In order of commits, this:
- Avoids
atexit(), since it's slow (dladdr() performs an expensive linear scan of the executable's symbol table)
- Lazily-loads well-known Crypto ciphers
- Once again avoids
atexit(), this time in OpenSSL.
On my mac, improves startups by ~15%:
$ hyperfine --warmup 25 --runs 100 'node -e "0"' './node -e "0"'
Benchmark 1: node -e "0"
Time (mean ± σ): 39.3 ms ± 2.2 ms [User: 31.6 ms, System: 6.4 ms]
Range (min … max): 36.5 ms … 55.0 ms 100 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 2: ./node -e "0"
Time (mean ± σ): 34.2 ms ± 2.1 ms [User: 26.4 ms, System: 6.4 ms]
Range (min … max): 32.4 ms … 49.3 ms 100 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Summary
./node -e "0" ran
1.15 ± 0.10 times faster than node -e "0"
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daniellockyer reacted with rocket emoji
|
Review requested:
- @nodejs/crypto
- @nodejs/gyp
- @nodejs/security-wg
- @nodejs/startup
- @nodejs/v8-update
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
atexit() calls dladdr() to find the image that
owns the callback. dladdr() performs an expensive
linear scan of the executable's symbol
table, so we now avoid it entirely.
Signed-off-by: Aviv Keller <[email protected]>
The Cipher::AES_* and Cipher::CHACHA20_POLY1305
constants were initialized by static initializers
while the executable is still being loaded.
Lazily-load them now, so they are only init'd on
first use.
Signed-off-by: Aviv Keller <[email protected]>
Now that crypto no longer initializes OpenSSL
from a static initalizer (see previous commit),
nothing requires OpenSSL to be torn down at process
exit. As mentioned in an earlier commit, `atexit`
is expensive, so we now once again avoid it.
Signed-off-by: Aviv Keller <[email protected]>
|
Please separate out the crypto ones into a separate PR and coordinate with @panva ... he has some other edits that may conflict.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
panva
commented
Aug 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
a1ba046 conflicts with #65484, please hold off updating crypto until those changes land.
|
avivkeller reacted with thumbs up emoji
Sorry, something went wrong.
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.
|
❌ Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.11%. Comparing base (ce40aa2) to head (2dffdbf).
⚠️ Report is 3 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #65549 +/- ##
==========================================
- Coverage 90.14% 90.11% -0.03%
==========================================
Files 751 751
Lines 253635 253645 +10
Branches 47793 47786 -7
==========================================
- Hits 228632 228574 -58
- Misses 16249 16315 +66
- Partials 8754 8756 +2
... and 38 files with indirect coverage changes
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
avivkeller reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Hi @avivkeller , could you rebase this pr? I guess after we can merge.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Funnily enough, I just independently discovered the atexit win and then found this PR. So I'd love to see this land 🙂
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
anonrig
anonrig approved these changes
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
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.
performance
Issues and PRs related to the performance of Node.js.
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.
|