Repository navigation
Conversation
Opens a document of 1,000 statements and applies 2,000 statement edits (rewrites, inserts, deletes, and changes of SQL function bodies), with diagnostics, hover, inlay hints and code actions in between. Afterwards the caches hold a parse result and a tree for exactly the statements of the document, and the memory retained is what it was after the first pass. The counting allocator moves to tests/common for both memory tests.
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 #951.
The memory test from #951 covers open, requests, close. It doesn't cover a long editing session, which is where a leak in the caches keyed by statement text would show: the parse results, trees and annotations of each statement (#913), the analysis (#929), and the hover snapshot (#913). This adds that test. It found no leak.
The test
tests/edit_churn.rsopens a document of 1,000 statements: tables, indexes, SQL functions with a body, and queries. It then applies 2,000 statement edits at random positions, using a seeded xorshift so failures reproduce. The edits rewrite, insert or delete a statement, or change the body of a SQL function, and keep the document within 10% of its length. They are applied in 500change_filecalls of 4 edits each. Hover and inlay hints run every 5 changes; diagnostics and code actions every 50. After a final full pass it asserts:parse_resultsandtreesagainststatementsfrom a new#[doc(hidden)] WorkspaceServer::document_cache_stats;To check that it catches a leak, I disabled the pruning in
Document::update_contentlocally. The test then failed with 3,440 parse results and 3,209 trees for 1,235 statements, and 85.9 MiB retained against 32.8 MiB.CHURN_STATEMENTSandCHURN_EDITSchange the workload. The counting allocator moves frommemory_bounds.rstotests/common/mod.rs, so both memory tests use it. Each stays in its own test binary, so nothing else allocates while it counts.Numbers
The small growth is the document's length and the analysis of the final pass, not the edits. The 20,000-edit run retains as much more as the 2,000-edit one.
Found along the way, not changed here
Every
change_filere-splits and re-scans the whole document for suppressions. For 1,000 statements in a debug build that is 33 ms of the 40 ms per change: about 32 ms for the statement splitter and 5 ms for suppressions. It is why the test applies several edits per change to stay fast in CI. It is linear in the file and pre-existing; an incremental split would be a separate change.