crypto: optimize normalizeAlgorithm dispatch hot path#62756
Closed
panva wants to merge 2 commits intonodejs:mainfrom
Closed
crypto: optimize normalizeAlgorithm dispatch hot path#62756panva wants to merge 2 commits intonodejs:mainfrom
panva wants to merge 2 commits intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
c23467e to
62dec56
Compare
62dec56 to
8cfb8ef
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62756 +/- ##
==========================================
- Coverage 89.69% 89.67% -0.02%
==========================================
Files 712 712
Lines 221273 221300 +27
Branches 42392 42386 -6
==========================================
- Hits 198473 198457 -16
- Misses 14634 14671 +37
- Partials 8166 8172 +6
🚀 New features to boost your workflow:
|
8cfb8ef to
cc1451b
Compare
f98babc to
06e2662
Compare
This comment was marked as outdated.
This comment was marked as outdated.
anonrig
approved these changes
Apr 21, 2026
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
3c42258 to
6ab9ee9
Compare
Replace the O(n) case-insensitive algorithm-name scan
with an O(1) SafeMap lookup. The map is pre-built at
module init alongside kSupportedAlgorithms.
Hoist the opts object literal used in normalizeAlgorithm
to module level to avoid allocating identical
{ prefix, context } objects on every call.
Pre-compute ObjectKeys() for simpleAlgorithmDictionaries
entries at module init to avoid allocating a new keys
array on every normalizeAlgorithm call.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
anonrig
approved these changes
May 4, 2026
Replace object spread in nested WebIDL conversion options with stable-shape ordinary objects. This keeps hot dictionary and sequence conversion paths from allocating null-prototype spread results. Apply the same pattern to Web Crypto converter wrappers that override allowResizable or enable [EnforceRange]. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Member
Author
|
With only the first commit: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1844/ With both commits: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1846 |
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
anonrig
approved these changes
May 6, 2026
Collaborator
|
Landed in e80b5d2...fa17dc2 |
nodejs-github-bot
pushed a commit
that referenced
this pull request
May 6, 2026
Replace the O(n) case-insensitive algorithm-name scan
with an O(1) SafeMap lookup. The map is pre-built at
module init alongside kSupportedAlgorithms.
Hoist the opts object literal used in normalizeAlgorithm
to module level to avoid allocating identical
{ prefix, context } objects on every call.
Pre-compute ObjectKeys() for simpleAlgorithmDictionaries
entries at module init to avoid allocating a new keys
array on every normalizeAlgorithm call.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #62756
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
nodejs-github-bot
pushed a commit
that referenced
this pull request
May 6, 2026
Replace object spread in nested WebIDL conversion options with stable-shape ordinary objects. This keeps hot dictionary and sequence conversion paths from allocating null-prototype spread results. Apply the same pattern to Web Crypto converter wrappers that override allowResizable or enable [EnforceRange]. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #62756 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace the O(n) case-insensitive algorithm-name scan with an O(1) SafeMap lookup. The map is pre-built at module init alongside kSupportedAlgorithms.
Use null-prototype objects for the generated operation tables and cached dictionary metadata so these internal lookups never consult Object.prototype.This causes a severe performance regression.Hoist the opts object literal used in normalizeAlgorithm to module level to avoid allocating identical
{ prefix, context }objects on every call.Pre-compute ObjectKeys() for simpleAlgorithmDictionaries entries at module init to avoid allocating a new keys array on every normalizeAlgorithm call.
Replace object spread in nested WebIDL conversion options with stable-shape ordinary objects. This keeps hot dictionary and sequence conversion paths from allocating null-prototype spread results.
Apply the same pattern to Web Crypto converter wrappers that override allowResizable or enable [EnforceRange].