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

Use MarkerIndex from text-document - #58

Merged
maxbrunsfeld merged 25 commits into
masterfrom
mb-marker-index
May 14, 2015
Merged

maxbrunsfeld merged 25 commits into
masterfrom
mb-marker-index

Conversation

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

This is an attempt to speed up text editing operations (inserting, replacing and deleting text) in the presence of a large number of markers. Markers' locations are stored as relative offsets in a b-tree, which allows textual updates to be handled in logarithmic time relative to the number of markers.

Side note: This PR also comes with a rewritten History class. Transactions are now implemented in terms of checkpoints, which allows for transactions within transactions, and (more notably) undo/redo within transactions. Thus, this closes the elusive atom/atom#5723.

Before

Currently, the MarkerManager objects maintain an interval-skip-list to support efficient lookups of markers by range. Updating this skip-list is expensive in the presence of large numbers of markers.

This is the flame graph for typing a newline in the middle of jquery.js while searching for all ; characters (2356 results):

screen shot 2015-05-12 at 8 20 59 pm

The time between the two red arrows is spent updating the skip-list. In this case, it took 54ms. The entire event took 147ms.

After

This is the flame graph for the same operation as above, with the new implementation. Note that it's not to scale with the graph above.

screen shot 2015-05-12 at 8 19 48 pm

The time between the two red arrows is spend updating the B-Tree. It took 1.7ms. The entire event took 47ms.

What now

Typing is still not fast in the presence of huge numbers of search results. The next slowest component in the flame graph above is emitting marker change events. Some of this may be due to packages, not atom-core code. I'll be investigating this slowness further as part of atom/atom#6692.

@maxbrunsfeld
maxbrunsfeld force-pushed the mb-marker-index branch 6 times, most recently from 9be25b8 to 21919cf Compare May 12, 2015 22:11
@maxbrunsfeld
maxbrunsfeld force-pushed the mb-marker-index branch 2 times, most recently from 73a166b to 142ef28 Compare May 13, 2015 05:28
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