perf(runtime): a latched-megamorphic read is answered from the receiver's shape key list - #11438
Conversation
…shape key list A site whose way state is latched megamorphic re-ran the whole generic miss machinery on every read: ~730 instructions on a 40-shape `o.kind` site (node: ~60), dominated by the receiver re-classification, the inherited-read-cache probe, the re-priming of a site that will not prime, and a by-name scan. Before that, the slow entry now asks the receiver's own shape record: an Ordinary, generation-0, hole-free shape stores an own inline key at its position in its canonical key list, so the key's position below the key count and the live inline slot count IS its inline slot, and the value is loaded from there. The site's compact word keeps an unmatchable low half and carries the last answered slot in its high half as the next guess, which the receiver's key list confirms before any scan. Dictionary, generation > 0, tombstones, spill, inherited keys, descriptors and `length` fall through unchanged.
|
Warning Review limit reachedNext included review available in 3 minutes. View limit detailsLimit details: You’ve used all 8 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review note: the suites, gap suite and A/B numbers in the description were measured on base Accessor safety: the new read path is kept away from accessors by the receiver's descriptor flag, which main still sets on every descriptor install. If that flag is ever removed, this path would also need to check the shape's accessor summary. |
What
A read site that has latched megamorphic sees 33+ shapes. It used to miss into the generic by-name machinery on every access, at about 713–731 instructions per read (node: ~51–60).
It is now answered from the receiver's own shape key list: find the key in the list the receiver's ShapeId names, then load that slot. The site holds nothing beyond the latch. The shape is the authority for which slot holds the key, and there is no side table.
tsc's AST sites are the main customer: 49% of its object reads miss the IC, because its node-kind sites see 33+ shapes.
This is the first stage of the megamorphic plan. Global key interning ("atoms") and an inline shape-confirmed slot guess were measured too. Together they took tsc to −5.1%, but they cost Zod +1.4% and tsc +15 MB RSS for reasons not yet explained. They are held for a follow-up that must meet a Zod-flat bar.
Numbers
Dedicated Linux host, both arms with matched build settings, each linking its own runtime. 5 interleaved rounds, identical output every round.
o.kindfixture, instructions per readtranspileModule.textsizeVerification
RUSTFLAGS=-D warningson runtime and codegen (lib and all targets): 0 diagnostics.cargo fmtis clean.--test-threads=1).verify_symbols.run_lint_gatespasses 100/102. The two failures are host-only (cargo xwin, and public-baseline freshness, which also fails on main).definePropertygetter,__defineGetter__, and a non-writable value.