Skip to content

Cache unresolved ReferenceType lookups - #1837

Merged
markwpearce merged 1 commit into
v1from
symbol-information-perf
Sep 25, 2026
Merged

markwpearce merged 1 commit into
v1from
symbol-information-perf

Conversation

@markwpearce

Copy link
Copy Markdown
Collaborator

Fixes #1835

A ReferenceType that doesn't resolve (eg. a symbol from another file, while processSymbolInformation walks a file before it's linked to a scope) got looked up again on every property access through the proxy - processTypeChain's isCallableType checks alone read kind ~10 times per chain entry. A miss can't become a hit until a symbol table changes or a scope gets linked, which already invalidates the cached hit from #1831, so misses are cached the same way now (except when the provider has no table yet).

Cold validate is 10-28% faster across the benchmark projects, edits up to ~35% faster, diagnostics identical. processSymbolInformation itself is about half what it was.

🤖 Generated with Claude Code

A ReferenceType that can't be resolved (eg. a symbol from another file, while
processSymbolInformation walks a file on its own) was looked up again on every
property access through the proxy - and checks like isCallableType read `kind`
many times. A miss can't turn into a hit until a symbol table changes or a scope
gets linked, which is what already invalidates the cached hit, so cache misses
the same way. Still don't cache when the provider has no table yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markwpearce markwpearce added this to the v1.0.0 milestone Sep 25, 2026
@markwpearce markwpearce added the create-package create a temporary npm package on every commit label Sep 25, 2026
@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new temporary npm package based on c046762. You can download it here or install it by running the following command:

npm install https://github.com/rokucommunity/brighterscript/releases/download/v0.0.0-packages/brighterscript-1.0.0-alpha.55-symbol-information-perf.20260925014927.tgz

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Updates ReferenceType resolution caching to avoid repeated symbol table lookups (including caching misses) and adds unit tests to validate the new caching behavior.

Changes:

  • Cache both successful resolutions and missing-symbol lookups (with invalidation via cache token + global mutation count).
  • Refactor resolveFromTable to take a symbol table instance (and avoid caching when no table is available).
  • Expand spec coverage for “miss caching”, mutation invalidation, and “no table yet” behavior.
File Description
src/​types/​ReferenceType.ts Refines resolution caching and resolveFromTable signature to reduce repeated lookups and cache misses safely.
src/​types/​ReferenceType.spec.ts Adds tests asserting resolution after symbol insertion, miss caching/invalidation, and no-table-yet behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/types/ReferenceType.ts
Comment thread src/types/ReferenceType.ts
Comment thread src/types/ReferenceType.spec.ts
@markwpearce
markwpearce merged commit 6d62c72 into v1 Sep 25, 2026
11 of 12 checks passed
@markwpearce
markwpearce deleted the symbol-information-perf branch September 25, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-package create a temporary npm package on every commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants