Repository navigation
Conversation
…and semantic tokens Hover, inlay hints and semantic tokens walked the file from the start and resolved every statement again on each request. The walk is now cached per document: a checkpoint of the catalog and the session every few statements, and the references of each resolved statement, keyed by a hash of the statements before it. A request resolves at most the statements since the last valid checkpoint before its range, and a repeated request only looks the references up. Inlay hints and semantic tokens are computed from the cached references.
This was referenced Oct 24, 2026
This branch has not been deployed
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.
Stacked on #918.
Hover, inlay hints and semantic tokens walked the file from the first statement and resolved every statement again on every request. Nothing was cached or shared, so on long files each request after an edit took seconds, and the editor sends several of them per edit.
What changed
server/editor_walk.rs,WorkspaceServer::walk_references):max(64, statements / 32)top-level statements it keeps a checkpoint of the catalog, the session and the migration section state. Each checkpoint is keyed by a hash of the statements before it and their sections (by position in the section list, direction and transaction mode, not by range, so edits before a section don't invalidate it).invalidate_schema_cache, and when the file is closed. Stale entries are pruned once there are more than twice as many as the document has statements.walk_statementsis gone.references_at, inlay hints and semantic tokens use the cached walk.pgls_inlay_hints::inlay_hints_of_referencesandpgls_semantic_tokens::semantic_tokens_of_referencescompute hints and tokens from the cached references instead of resolving again. The old entry points remain as wrappers that resolve first.Document::iter_fromandDocument::statement_rangeslet the walk start at a top-level statement.Timings
Release build, best of 3, on a loaded shared machine. The files are the migration-style benchmark from the analysis: per group a table, an index, a SQL function and a query. The benchmark is in
server.perf_tests.rs(cargo test --release -p pgls_workspace --lib perf_tests -- --ignored --nocapture --test-threads=1). "Before" is the same benchmark on #918, where every request costs the same. "Cold" is the first request after clearing the cache, "warm" a repeated request."Before" for the edit row is the sum of the two requests, since nothing is cached.
What this doesn't fix
on_hoverstill iterates the whole document with.last()and buildssnapshot_before. Both are being fixed on main; with that, hover gets the warmreferences_attime above.Tests
test_editor_walk_cache_follows_edits: a 300-statement file (so checkpoints exist), tokens and hints for the tail and the whole file after renaming a column before, inside and after the cached part, compared with a fresh workspace each time. Breaking the hash checks makes it fail. All existing hover, inlay hint, semantic token and LSP tests pass.Conflicts
ParseIterator,Documentand hover are also changed on main (iterator recursion, statement caches, hover's double walk). Expect conflicts indocument.rsand inon_hover/references_at. This also conflicts with #904 inpgls_semantic_tokens/src/lib.rs(the top ofsemantic_tokens).