Skip to content

resolve: check js_decl_scope_memo before the file/tree loads - #569

Merged
bompus merged 1 commit into
fork/consolidatedfrom
perf/js-decl-preamble-reorder
Oct 28, 2026
Merged

bompus merged 1 commit into
fork/consolidatedfrom
perf/js-decl-preamble-reorder

Conversation

@bompus

@bompus bompus commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #566 — the memo sat behind read_file, js_binding_tree (a format! key + tree-LRU + Rc::clone) and two js_unit_to_byte scans, so hits still paid the preamble. A gate-cost analysis (names.rs gate chain) named this the top residual:

  • Memo check moved ahead of the loads: Some(None)/global → Some(true) with no source read; None → None with nothing; only Some(scope) reads the file for the ref Point.
  • is_lexically_reachable's bare regex gets a one-entry memo keyed on reference_name (same name for every candidate in a ref's loop).
  • prefer_adjacent_implementations skips its HashSet build + 2 String allocs/candidate unless a .d.ts candidate exists.

Validation

  • kernel-resolve-parity.test.ts: 8/8.
  • pretix corpus gate: exact parity (32799/73404/165700); resolution 4.73s → 4.57s (~3.5%).
  • All verdict-identical reorderings — no gate semantics changed.

The #566 memo sat behind read_file, js_binding_tree (format! + tree LRU
+ Rc clone) and two js_unit_to_byte scans — the preamble was the residual
cost the memo couldn't see. A hit now needs no tree; a missing or global
scope needs no source either.

Two adjacent same-loop wins: is_lexically_reachable's bare regex gains a
one-entry memo keyed on reference_name, and prefer_adjacent_implementations
skips its HashSet build unless a .d.ts candidate exists.

pretix parity exact (32799/73404/165700); resolution 4.73s -> 4.57s.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between a403ef5 and 502c51e.

Files selected for processing: 3
  • codegraph-kernel/src/resolve/js_scope_upstream.rs
  • codegraph-kernel/src/resolve/mod.rs
  • codegraph-kernel/src/resolve/names.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bompus

bompus commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bompus
bompus merged commit 2d385c6 into fork/consolidated Oct 28, 2026
4 checks passed
@bompus
bompus deleted the perf/js-decl-preamble-reorder branch October 28, 2026 00:46
bompus added a commit that referenced this pull request Oct 28, 2026
Adds the six landed rows to the benchmark follow-up table and updates the
measured head + README revision. pretix settle: 4.73 -> ~3.5 s (-26%,
two profiled runs) across #569-#572 with exact graph parity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant