-
-
Notifications
You must be signed in to change notification settings - Fork 163
fix: eliminate double prototype walk on absent property reads #11383
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
Changes from all commits
Commits
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,41 @@ | ||
| Fixed an absent property read costing `2^depth` generic-getter entries on a | ||
| prototype chain (#10877). The object-getter tail read the receiver's prototype | ||
| twice on an own-key miss, and each read re-enters the tail one level up, so the | ||
| work doubled per hop: | ||
|
|
||
| - **`Object.create` chains**: `prototype_override::inherited_field_if_overridden` | ||
| walked the recorded chain, missed, and the tail's closing | ||
| `resolve_inherited_field` walked the same chain again from the same | ||
| receiver. It now reports `InheritedRead::Missed` and the tail skips its own | ||
| walk. | ||
| - **`F.prototype = new G()` chains**: a `new F()` instance reaches | ||
| `F.prototype` both through F's synthetic class id | ||
| (`resolve_proto_chain_field_*`) and through its recorded per-object link | ||
| (`resolve_inherited_field`). The class-id walk now reports a prototype it read | ||
| in full that answered exactly `undefined` | ||
| (`resolve_proto_chain_field_noting_miss`); the tail skips the per-object walk | ||
| when that is the receiver's recorded prototype. A `null` answer does not | ||
| qualify — the class-id walk skips `null`, which the per-object read must | ||
| still return. | ||
|
|
||
| Observable effect beyond speed: an inherited getter that returns `undefined` | ||
| ran `2^depth` times per read (once per re-entry); it now runs once, as in node. | ||
| `class C extends B` chains were already linear and are unchanged. | ||
|
|
||
| Measured (`perry-dev`, 20,000 absent reads, min of 3 wall-clock): | ||
|
|
||
| | chain | depth | before | after | | ||
| |---|---:|---:|---:| | ||
| | `Object.create` | 1 | 0.103 s | 0.046 s | | ||
| | `Object.create` | 4 | 0.803 s | 0.075 s | | ||
| | `Object.create` | 8 | 12.50 s | 0.120 s | | ||
| | `Object.create` | 10 | 51.4 s | 0.151 s | | ||
| | `F.prototype = new G()` | 1 | 0.115 s | 0.054 s | | ||
| | `F.prototype = new G()` | 4 | 0.833 s | 0.082 s | | ||
| | `F.prototype = new G()` | 8 | 13.52 s | 0.132 s | | ||
| | `F.prototype = new G()` | 10 | > 60 s | 0.156 s | | ||
|
|
||
| Regression coverage: `test-files/test_gap_10877_proto_chain_miss_linear.ts` | ||
| pins exact getter call counts on both chain kinds (keyless and shaped | ||
| receivers), a `null`-valued inherited property, hits and middle links, and a | ||
| 1,000-miss loop on 24-deep chains that did not finish in 120 s before. |
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.
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.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
Keep the prototype identity stable across the getter call.
If a getter causes GC to move
proto_obj,class_prototype_object(cid)returns its new address, but this comparison uses the old address. The comparison then leavesread_missunset. Both object-getter tail paths can read the prototype again, repeating the getter and restoring the deep-chain performance problem. Rootproto_objbeforejs_object_get_field_by_name, then compare its updated address after the call. The runtime documents that getter execution can move active prototype owners. (raw.githubusercontent.com)🤖 Prompt for AI Agents