Skip to content

Cache ReferenceType resolution and skip allocations in getSymbol - #1831

Merged
markwpearce merged 3 commits into
v1from
referencetype-resolve-cache
Sep 24, 2026
Merged

markwpearce merged 3 commits into
v1from
referencetype-resolve-cache

Conversation

@markwpearce

@markwpearce markwpearce commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses #1827.

  • ReferenceType keeps its resolved type until a scope gets linked (new cache token) or any symbol table changes (new SymbolTable.mutationCount). Every property access on the proxy was doing the full lookup again
  • getSymbol skips the lookup filter closure on unordered tables, skips the pocket table augment when there aren't any, and doesn't copy own-table hits through addAncestorInfo

Also tried a getSymbol result memo on top of this (cache token + mutation count, same as ReferenceType). Diagnostics were identical, but it's a net loss now that lookups are cheap - load up to 22% slower, validate +9% to -8%, heap +3-6%. So it's not in here.

benchmark:scenarios, best of 3 vs alpha.55, diagnostics identical, heap unchanged:

project validate revalidate
roku-googlephotos -43% -39..-49%
jellyfin-roku -45% -30..-39%
brighterscript-game-engine -66% -61..-65%
Unamed OTT App -46% -35..-39%

On a big client project (bslint + rooibos, no profiler): validate 34.5s -> 25.3s (-27%), wall -21%, peak RSS -310MB, same 13040 errors / 8139 warnings. In the profile ReferenceType.resolve goes 2.18s -> 0.06s and getSymbol 7.37s -> 2.95s.

Also tried turning off the SymbolTable type cache on top of this - no diagnostic changes and validate is about the same, but load gets up to 31% slower, so it stays.

🤖 Generated with Claude Code

markwpearce and others added 2 commits September 24, 2026 11:31
…ble changes

Every property access on a ReferenceType proxy was doing the full symbol table lookup again. Now it keeps the resolved type until the cache token changes or anything bumps the new `SymbolTable.mutationCount`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- unordered tables only need the flags check, no lookup filter closure
- only augment with pocket table results when the table has pocket tables (it was a no-op otherwise, but allocated options/arrays every level)
- don't map own-table hits through addAncestorInfo, it was an identity copy

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

Copy link
Copy Markdown
Contributor

Hey there! I just built a new temporary npm package based on 41376ee. 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-referencetype-resolve-cache.20260924153536.tgz

@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new temporary npm package based on 517c96a. 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-referencetype-resolve-cache.20260924155835.tgz

@markwpearce
markwpearce merged commit b465b14 into v1 Sep 24, 2026
11 checks passed
@markwpearce
markwpearce deleted the referencetype-resolve-cache branch September 24, 2026 16:07
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 performance preformance-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants