mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-27 02:50:30 +01:00
b0e921dadc
Part of #52410 With thousands of changed files open in Uncommitted Changes, scrolling and typing lag while files keep changing on disk. One cause is `excerpt_boundaries_in_range`. It skipped excerpts outside the range but never stopped, so a one-line edit in file k made the block map walk every excerpt after k. The split diff has two block maps, and each changed file sends several edit events, so this ran many times per file. The skip was there because the walk could begin one excerpt too early. The setup checked whether the cursor was at the start of a diff transform, and took that as the start of an excerpt. A range starting on a transform in the middle of an excerpt then made the walk begin with an excerpt before the range. The setup now seeks to the excerpt start before that check, so the walk never sees an excerpt before the range and can return at the first one outside it. Measured on a repository with 3,600 changed files, opened over SSH, with 300 files rewritten each second: | Share of main thread | Before | After | |---|---|---| | `excerpt_boundaries_in_range` | 32.3% | 0.1% | | `BlockMap::sync` | 37.6% | 4.5% | In a Criterion benchmark with one editor on a 4,000-file diff multibuffer, changing 16 files and drawing a frame takes 10% fewer main-thread instructions (370.6M to 333.7M). Editing one character takes 7.8% fewer. These numbers are from the first version of this PR, which stopped at the range end but kept the skip. The walk in the final version visits the same excerpts or one fewer. Release Notes: - Improved responsiveness of the Uncommitted Changes view when many files change at once.