-
-
Notifications
You must be signed in to change notification settings - Fork 158
perf(runtime): the last four per-element key scans resolve via the shape index (read loop −10.5%) #8971
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
Merged
Merged
perf(runtime): the last four per-element key scans resolve via the shape index (read loop −10.5%) #8971
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
824c746
perf(runtime): read fast lane resolves keys via the shape index, not …
2a258af
perf(runtime): the three remaining per-element key scans use the shap…
36e3524
Merge commit 'refs/tmp/pr8971' into b8971
xxxxxxxxxxxxx 26abfa3
fix(object): if let, not a for loop over an Option
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| The last four per-element key scans on the property paths now resolve through | ||
| the shape hash index. | ||
|
|
||
| #8936 and #8950 replaced the `js_array_get` + `js_string_key_matches` walks on | ||
| the `[[Set]]`, `delete` and `[[Get]]`-fallback paths, but four copies survived | ||
| in the plan-miss and cache-miss fallbacks: | ||
|
|
||
| - `js_object_get_field_by_name`'s FAST LANE — the read-plan cache's miss path, | ||
| a full walk of up to 4096 keys. The plan is epoch-guarded and flushed on | ||
| every GC and on descriptor / prototype / delete mutations, so this ran in | ||
| full each time it was flushed. It put `js_string_key_matches` at **9.6% self | ||
| time** in a computed-key read loop, second only to the entry itself. | ||
| - the write fast path's read-plan miss fallback, and | ||
| - the write tail and the read tail, whose loops walked every key (two of them | ||
| via `js_array_get`, which additionally probes each index for a per-index | ||
| accessor). | ||
|
|
||
| All four go through `keys_find_slot_by_key_ptr`: shape hash index first, raw | ||
| dense-slot scan as its own fallback and correctness backstop. The two tail | ||
| sites keep their original `js_string_key_matches` test as the gate, so the | ||
| resolver can only narrow the candidate slot, never widen what is accepted. | ||
|
|
||
| Interleaved A/B, min-of-15 at quiet load (node on the same host in brackets): | ||
|
|
||
| | loop | main | this PR | | | ||
| |---|---|---|---| | ||
| | read only | 38 ms (25) | **34 ms** | −10.5% min, −18.6% mean | | ||
| | combined overwrite | 79 ms (29) | **77 ms** | −2.5% min, −13.2% mean | | ||
| | write only | 44 ms (23) | 43 ms | −2.3% | | ||
|
|
||
| The read-only loop is where this lands: in the combined loop the write primes | ||
| the read plan, so the read never reaches the miss path at all. | ||
|
|
||
| Computed-key differential output (delete/re-add ordering, `Map`/`Set` keys, | ||
| the SSO boundary, non-ASCII, floats, negatives, 1e21) is byte-identical to | ||
| node. Suite: 2779 passed, 0 failed. | ||
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
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
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
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
Oops, something went wrong.
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.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Prefix the issue references with prose.
Line 4 triggers markdownlint MD018 because it starts with
#8936. Start the sentence withIssuesto retain the issue references and pass the lint check.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 4-4: No space after hash on atx style heading
(MD018, no-missing-space-atx)
🤖 Prompt for AI Agents
Source: Linters/SAST tools