Allocate node and symbol IDs in per-checker blocks - #4741
Open
mds-ant wants to merge 1 commit into
Open
Conversation
Node and symbol ids are assigned lazily on first touch from two global atomic counters. With multiple checkers running concurrently the ids each checker sees are interleaved with every other checker's, so the paged link stores (which index 256-entry pages by id) end up allocating pages that are mostly slots for entities the checker never touches, and the first-touch assignment itself is a contended atomic increment on symbols and nodes shared between checkers. Give each checker an `ast.IdAllocator` that reserves page-aligned blocks of ids from the global counters and hands them out locally. The first checker to touch a node or symbol is almost always the one that owns the file it belongs to, so ids now cluster per checker and the pages of `symbolNodeLinks` and `valueSymbolLinks` become dense. Callers outside the checker keep using the plain `GetNodeId`/`GetSymbolId`.
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
Adds per-checker, page-aligned ID allocation to improve paged link-store density and reduce atomic-counter contention.
Changes:
- Introduces adaptive block-based node and symbol ID allocation.
- Integrates allocators into checker paged link stores.
- Adds allocator exclusivity coverage and updates related documentation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/core/linkstore.go |
Exposes the link-store page size. |
internal/checker/links.go |
Uses checker-local ID allocation for paged stores. |
internal/checker/checker.go |
Initializes each checker’s allocator. |
internal/ast/utilities.go |
Moves global ID logic into ids.go. |
internal/ast/ids.go |
Implements global and block-based ID allocation. |
internal/ast/ids_test.go |
Tests page ownership across allocators. |
internal/api/session.go |
Updates symbol-ID documentation. |
Member
|
@typescript-bot perf test this |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
lspComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Context
Node and symbol IDs are assigned on first touch from two global counters. With several checkers running at once, the IDs each checker sees are interleaved with everyone else's, so the paged link stores from #4329 (which allocate 256-slot pages keyed by ID) materialize pages that are mostly slots for entities the checker never touches. The first-touch assignment is also a contended atomic increment on shared symbols and nodes.
This PR
In this PR, we give each
Checkeranast.IdAllocatorthat reserves contiguous, page-aligned blocks of IDs from the global counters and hands them out locally. The first checker to touch a node or symbol is usually the one that owns its file, so IDs cluster per checker and the pages ofsymbolNodeLinksandvalueSymbolLinksbecome dense. Block size grows from 256 IDs up to 4096 IDs so that short-lived checkers waste at most a page while batch checkers still amortize reservations.Performance
VS Code
src(8,474 files,--noEmit):Memory
Link store pages are no longer duplicated across checkers for entities only one checker touches:
This PR was assisted by Claude Code.