Skip to content
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

Optimize rendering of decorations in overview ruler #3703

Closed
Tyriar opened this issue Mar 22, 2022 · 3 comments · Fixed by #3723
Closed

Optimize rendering of decorations in overview ruler #3703

Tyriar opened this issue Mar 22, 2022 · 3 comments · Fixed by #3723
Assignees
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Mar 22, 2022

VS Code issue: microsoft/vscode#145751

Could repro this slowness by filling the buffer and then searching for a single letter, this is on a 12th gen i7 (fast modern CPU):

image

A similar thing happens when pressing enter in this state since we don't do any diffing, just clear and re-render.

Ideas to explore:

  • Move from rendering each decoration to calculating colored zones which merge similar rectangles into the same zone and render them
  • If the buffer is full, explore shifting the texture up depending on how much scrolling occurs (might be tricky to get right)
@meganrogge
Copy link
Member

meganrogge commented Mar 22, 2022

When the buffer is full, could we just set the top of the canvas?

What I mean is let's say buffer length is 50. When line 51 is added, we set top of the canvas to -decorationHeight

@meganrogge
Copy link
Member

meganrogge commented Mar 22, 2022

For the case when the buffer isn't full, i was wondering if there's some transform (math) we could do to the canvas to shrink it height wise proportional to the amount that gets added instead of having to actually draw the decorations.
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform

@Tyriar
Copy link
Member Author

Tyriar commented Mar 22, 2022

When the buffer is full, could we just set the top of the canvas?

We could essentially do this by drawing the canvas to itself via drawImage(canvas, ...), but getting it just right might be tricky. Say 1 row gets trimmed off the top, that might not end up being a complete pixel depending on the dimensions of the terminal, it would be a floating point number that needs to be tracked so the remainder can be applied next. It probably won't end up working in the end as a rerender would end inevitably up shifting some of the pixels.

A better approach would probably be to do the color zone idea and explore shift that instead if performance is still poor after that change.

For the case when the buffer isn't full, i was wondering if there's some transform (math) we could do to the canvas to shrink it height wise proportional to the amount that gets added instead of having to actually draw the decorations.

You could do some transform of the existing image but I think it suffers from the same problems, in addition to blurriness coming in as well.

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

Successfully merging a pull request may close this issue.

2 participants