-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Avoid creating new ArrayBuffers when reducing the size of the buffer #4112
Comments
@Tyriar This a really good idea, it would lower CPU stress for multiple shrinking events in a row. The halving also sounds good to me, it would also lift some burden from expanding resizes within the old upper limit. Are the resize events de-bounced? Like the event would not get triggered for every single number, if one changes from 80 to 50 cols fast enough? |
Did a quick test with a 100k scrollback terminal filled (only testing col shrinking): old ~320ms vs. new ~160ms for resize runtime - speed doubled. 😺 Seems nodejs does not support |
Here a few numbers with the new approach. Again done on 100k scrollback, from shriniking/enlarging between 55 -65 cols. They should be JIT'ed (did some warmup before profiling), and show 2 +-1 col events:
Without the patches all actions look like the last image. With the patches we gain:
Further take aways:
@Tyriar Idk how your reflow logic works, but wonder why |
Something weird is going on during enlarging in the demo. If I increase cols by one I get the following Note that I changed cols to 87, which is correctly announce by the first Edit: |
Runtimes w'o zoomlevel madness:
|
This is up to the embedder. It's debounced by 50ms in VS Code as we still want it to be relatively responsive, so multiple resizes can easily happen in a second. |
See #4109 (comment)
I think we could actually change this:
xterm.js/src/common/buffer/BufferLine.ts
Lines 335 to 336 in f9db65c
To:
That will keep the same ArrayBuffer, but use a different view of it. We wouldn't free the memory but maybe we should only do that either when the view is < 1/2 the size of the buffer, or defer the clean up to an idle timeout? It doesn't make sense to do so many allocations if they're being thrown away immediately after several resizes.
We could do something similar here:
xterm.js/src/common/buffer/BufferLine.ts
Lines 347 to 348 in f9db65c
The text was updated successfully, but these errors were encountered: