Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Re-scan only changed region when buffer changes - #394

Merged
maxbrunsfeld merged 1 commit into
masterfrom
mb-optimize-buffer-rescan
May 27, 2015
Merged

maxbrunsfeld merged 1 commit into
masterfrom
mb-optimize-buffer-rescan

Conversation

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

⚠️ Depends on Atom features that won't be released until 0.202 ⚠️

Problem

Currently, whenever a buffer stops changing, we re-scan the entire buffer for strings matching our search. This can take a long time and can delay the UI responding to typing.

Here's a flame graph taken while typing in the middle of jQuery 2.0.3 (88,000) lines while searching for the string e (20769 results). Rescanning took 681 ms.

before

After

This new approach is to keep track of the buffer changes that occur between scans, and only rescan the changed regions.

Here's a flame graph for the same operation as above. Rescanning took 8 ms.

after

This uses a new (and for the time being, undocumented) feature of text-buffer: the Patch class that allows text changes to be aggregated and grouped (see atom/text-buffer#62).

Use Patch to aggregate changes between deferred
scans of the buffer.
@maxbrunsfeld
maxbrunsfeld force-pushed the mb-optimize-buffer-rescan branch from c98162e to 6f57aca Compare May 27, 2015 21:57
maxbrunsfeld pushed a commit that referenced this pull request May 27, 2015
Re-scan only changed region when buffer changes
@maxbrunsfeld
maxbrunsfeld merged commit 2612c8a into master May 27, 2015
@maxbrunsfeld
maxbrunsfeld deleted the mb-optimize-buffer-rescan branch May 27, 2015 22:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant