perf: inline getArg(source) in generatedPositionFor#73
Merged
Conversation
b301161 to
6e7c982
Compare
4 tasks
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.
Summary
Follow-up to #72:
generatedPositionForstill readssourcethroughutil.getArgeven after #72 inlinedline/column. Same megamorphic-call-site exposure — and same magnitude of payoff once inlined.sourcecan legitimately benull(sources arrays accept null entries), so thetypeof !== 'number'validation from #72 doesn't fit. Behavior is preserved by deferring the "is a required argument" throw to the slow path:_findSourceIndexruns first; only if its lookup fails AND the key is absent fromaArgsdoes the throw fire. Defined values (the hot path) take a single property access and never see theincheck.Results (bench-diff vs main, SOLO)
babel.min.js.map (2 runs, full-phase third run for sanity)
Full-phase run also showed Trace speed (random) at +11.9% as a positive halo (V8 IC sharing across opf/gpf paths).
vscode.map (5 runs)
Median +1.0%, mean +2.5% — within noise. (An earlier draft that did the
'source' in aArgscheck on the hot path regressed vscode by a reproducible 5–16%; moving the check to the slow path eliminated that.)Behavior
Throw on missing
sourcekey is preserved:gpf({line: 1, column: 0})still throwsError('"source" is a required argument.'). The throw is just delayed until after the slab lookup, which is fine because the lookup is cheap and the throw is fatal anyway.Test plan
yarn test— 205/205 non-TODO tests passincheck to the slow path