Skip to content

perf(tsrx): speed up local export scope lookups - #7

Merged
trueadm merged 1 commit into
tsrx-org:mainfrom
jonkwheeler:optimize/export-scope-lookups
Aug 27, 2026
Merged

trueadm merged 1 commit into
tsrx-org:mainfrom
jonkwheeler:optimize/export-scope-lookups

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Modules with many named local exports no longer rescan every declaration for every exported name. Parser behavior remains unchanged while local export validation now scales linearly with the number of declarations and exports.

Performance

The benchmark parses a module with 6,000 const declarations and one export list containing all 6,000 names. Each result is the median of five runs with the same semantic digest.

Metric Before After Change
Parse time 229.98 ms 71.21 ms 69.0% lower (~3.2× faster)

Validation

  • TSRX utility suite: 19 files and 472 tests passed
  • Focused export-cache regression tests: 2 tests passed
  • tsgo --noEmit -p packages/tsrx/tsconfig.json passed
  • Prettier and git diff --check passed
  • The benchmark preserved declaration count, export count, and semantic digest

This is an internal parser performance change with no public API, compiler-output, dependency, or changeset impact.


Note

Low Risk
Internal parser caching in export validation only; behavior is covered by new regression tests and existing suites, with no public API change.

Overview
Speeds up named export { … } validation when a module has many local bindings and export lists, without changing parse results or diagnostics.

checkLocalExport in the TSRX parser no longer scans each scope’s full lexical / var arrays on every exported identifier. It keeps a per-scope incremental cache (WeakMap → Set of names plus array lengths) and only merges new entries when those arrays grow, so work scales with declarations plus exports instead of exports × declarations.

Regression tests cover late declarations (e.g. export { first } then const second then export { second }) and unchanged errors for undefined exports.

Reviewed by Cursor Bugbot for commit b9c65e1. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@jonkwheeler is attempting to deploy a commit to the Ripple Team Team on Vercel.

A member of the Team first needs to authorize it.

@jonkwheeler
jonkwheeler requested a review from trueadm August 27, 2026 13:09
@trueadm
trueadm merged commit 53b893b into tsrx-org:main Aug 27, 2026
8 checks passed
@jonkwheeler
jonkwheeler deleted the optimize/export-scope-lookups branch October 20, 2026 12:54
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.

2 participants