New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement decorations as an interval tree #36410

Merged
merged 65 commits into from Oct 20, 2017

Conversation

Projects
None yet
3 participants
@alexandrudima
Member

alexandrudima commented Oct 17, 2017

This PR reimplements decorations in the editor buffer as an interval tree which stores relative offsets. The goal is to make inserting, removing and editing be a lot faster when dealing with a large number of decorations. Memory usage savings are also a nice win.

This should help with increasing the limits for #496 and #1110

Further optimizations (on top of an interval tree):

  • storing two interval trees, one with decorations that show up in the overview ruler, one with decorations that do not. The reason is that the overview ruler paints all the decorations, not just the ones in the viewport.
  • the decorations overview ruler has been reimplemented to avoid allocations almost entirely.
  • fetching decorations to render in the viewport now eliminates hidden ranges (i.e. folded ranges) and avoids visiting decorations that would not be visible anyways.
  • the find widget, when having more than 1k results, will approximate overview ruler decorations and will create a separate set of decorations for the overview ruler.

checker.txt + Bracket Pair Colorizer ~ 38,177 decorations

Before After
removing+adding 194.5ms (52.5+56.3+85.7) 55.7ms (25.4+14.8+15.5)
typing \n (_pushEditOperations) 148.7ms 1.6ms
model mem usage 3,865,672 3,858,468
model mem usage with decorations 40,826,928 6,650,196

jquery.js + Search for e + no find limit ~ 24,034 decorations (22,974 find matches)

Before After
adding 230.3ms 38.9ms
removing 759.6ms 23.9ms
typing \n (_pushEditOperations) 33.1ms 0.7ms
model mem usage 2,667,304 2,630,636
model mem usage with decorations 15,269,076 4,228,524

alexandrudima added some commits Oct 12, 2017

@alexandrudima alexandrudima self-assigned this Oct 17, 2017

@alexandrudima alexandrudima merged commit 55b2ff2 into master Oct 20, 2017

1 of 5 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
license/cla All CLA requirements met.
Details

@alexandrudima alexandrudima deleted the alex/interval-tree branch Oct 21, 2017

@eamodio

This comment has been minimized.

Show comment
Hide comment
@eamodio

eamodio Oct 23, 2017

Contributor

@alexandrudima THIS IS AWESOME! I'm seeing a great improvement in decoration application & removal -- and even better it also seems stable (performance-wise) -- before adding a LOT of decorations would be slow-ish but ok, but removing them would sometimes get worse and worse over time.

Thank you!!!

Contributor

eamodio commented Oct 23, 2017

@alexandrudima THIS IS AWESOME! I'm seeing a great improvement in decoration application & removal -- and even better it also seems stable (performance-wise) -- before adding a LOT of decorations would be slow-ish but ok, but removing them would sometimes get worse and worse over time.

Thank you!!!

@lkytal

This comment has been minimized.

Show comment
Hide comment
@lkytal

lkytal Nov 11, 2017

Brillant work.

lkytal commented Nov 11, 2017

Brillant work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment