This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
Optimize marker observation - #7023
Merged
Merged
Conversation
This allows us to use the .toEqual matcher to compare Set objects.
Signed-off-by: Nathan Sobo <[email protected]>
17 of 20 tasks
Signed-off-by: Nathan Sobo <[email protected]>
maxbrunsfeld
force-pushed
the
mb-optimize-marker-observation
branch
from
May 30, 2015 00:29
fb5cd68 to
eed1ecb
Compare
Conflicts: src/text-editor-component.coffee src/text-editor-presenter.coffee
Signed-off-by: Nathan Sobo <[email protected]>
maxbrunsfeld
force-pushed
the
mb-optimize-marker-observation
branch
from
June 4, 2015 00:58
deef930 to
f5895d8
Compare
maxbrunsfeld
pushed a commit
that referenced
this pull request
Jun 4, 2015
Optimize marker observation
This was referenced Jun 5, 2015
Closed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Depends on new
text-bufferfeatures. See atom/text-buffer#66.This is one of several optimizations aimed at addressing Atom's slowness when an editor has a lot of markers (e.g. find-and-replace results, spell-check highlights).
Problem
Currently, each decorated marker in the editor is individually observed by the
TextEditorPresenterusingMarker::onDidChange. Even though the presenter doesn't do much work for markers that are off-screen, just emitting all these change events becomes expensive when there are 10,000+ markers. The main cost is computing each marker's screen coordinates based on the underlying buffer coordinates.This is a flame graph taken while inserting a newline into a file 2800 line file with 17000 search results. It took 1.5 seconds. The region between the red arrows is emitting marker change events.
Solution
We've added a new API onThe presenter now simply recomputes decoration states whenever any markers update. It determines that markers have updated using the text-buffer'sTextEditorcalled::observeMarkers(), which allows you to observe any marker changes within a particular region of the editor.::onDidUpdateMarkersmethod. This means that most markers are not observed, so they can avoid observing changes to their underlyingtext-buffermarker, preventing unnecessary screen-coordinate translations.The same operation as performed above now takes 170 ms. Still not fast, but we've removed a bottleneck.