Repository navigation
Conversation
…cache A thousand edits of a 1,000-statement document that rewrite, insert and delete statements at random positions, alter and drop tables and change function bodies, with semantic tokens, inlay hints and hover in between and requests that edits make outdated while they run. The walk cache stays within its bounds and holds exactly the current statements after a full walk, and the retained memory doesn't grow with the edits. The counting allocator moves to a module that both memory tests share.
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 #954.
The memory test from #953 covers open → requests → close, but not a long editing session. That is where a leak in the walk cache would show: checkpoints and references of earlier versions, or document snapshots kept alive by outdated requests.
The test (
crates/pgls_workspace/tests/memory_churn_tests.rs)change_fileedits by default (MEMORY_EDITSchanges this). The edits come from a seeded random generator, at random positions:alter table ... add columndrop tableDeletes keep the document at about 1,000 top-level statements.
It uses the counting allocator of #953, which moves to
tests/common/counting_allocator.rs. Each memory test has its own test binary, because the counter is global per binary.WorkspaceServer::editor_walk_size(#[doc(hidden)]) reports a document's cached statements, the ones that belong to its current version, and its checkpoints.Results (debug build)
No leak found, so there is no fix in this PR. Stale references are pruned once there are about twice as many as the document's statements, checkpoints stay at the per-document maximum, and outdated requests don't keep document snapshots alive. Retained memory even drops slightly. It is dominated by the document's statement caches (AST/CST), which depend on the statement texts. The default of 1,000 edits keeps the test at about a minute in debug: each
change_filere-splits the whole document, about 30 ms per edit in a debug build.