-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Performance regression with maximized window on 2.0.0-canary.9 #2592
Comments
I'm guessing this is what @rauchg was seeing. I suspect this branch will fix the issue https://github.com/Tyriar/xterm.js/tree/1063_minimize_drawing by no longer redrawing everything but only the first 4 columns. |
Upstream issue: xtermjs/xterm.js#1063 |
@chabou also how big is your windows cols/rows exactly when you're seeing these 500ms frames? |
Looking at this it look like it's close to be fullscreen? |
I'm running into this issue too. It's especially bad on my 1440p screen, to the point where I can't use hyper, since every keystroke in vim causes a 300ms (or more) frame. I tend to have around 320 columns and maybe 90 rows or so. |
I cannot reproduce close this this level of slowdown. Can you share your vi config? Something that could potentially explain this is if you're styling the text/backgrounds using truecolor/255 color? |
Here's my vimrc. It's not easy for anyone to pick up and use though, because it depends on a large set of plugins installed using git submodules. It turns out that I was setting the background color with vim (though I was just setting it to the same color as my terminal's background, and I'm not using 256 colors). Running
and running A took a look at how alacritty does this, and it looks like they populate a glyph cache/atlas when drawing characters, so that the cache is filled with character color combinations that are actually in use, whereas xterm.js is just using a static cache. I'd be interested in trying to implement a similar approach (maybe a simple LRU cache) in xterm.js. |
Unsure if this is related, but I have a 4k screen, Hyper maximised, and experiencing >1s pauses. Worse in vim, going up sometimes to ~10s pauses. Doesn't happen on stable. |
@bgw yeah we only cache with the standard background, and then turn the bg transparent to retain SPAA and make it look decent with overlapping chars. A dynamic cache is something I've been thinking about for a while, it would definitely be cool but it would be a fair bit of effort to implement. |
I'm using https://github.com/yosiat/oceanic-next-vim Color theme. Testing with a 320colx90rows term : frame render time is 500ms in vim. Very nice catch @bgw 👍 |
There are also huge gains that could be made if the user doesn't care about subpixel AA as then the background color doesn't need to be cached as well. |
I can also confirm that disabling the theme made it mindbogglingly fast 🤣 |
Great detective work @bgw ! |
On second thought we would still need to check the background, but it would be based on the luminance of the color, not the exact color. And some backgrounds should be able to share without it looking weird. |
Works around vercel/hyper#2592, which is a performance issue with xterm.js' character caching.
+1 on this issue, I encountered it this morning as well. canary9 caused this, but not canary 8. |
Disabling the theme made it fax again. I was using oceanic next theme as well. I'm using nvim, and couldn't quite apply @bgw's fix. I guess I just don't know how to apply it. |
I found that disabling
Gives me the best workaround performance on Neovim. |
I removed |
FYI, I'm working on an implementation of a dynamic character atlas for xterm.js that allows characters with different background colors to be cached, which should fix most people's performance issues. It generates a character atlas that looks something like: The current implementation is here, but it's still pretty buggy, and needs a bit of work and cleanup before I'm comfortable making a PR out of it, but things are coming along! cc @Tyriar |
@bgw nice! I had a quick look at your branch, this was the main bit I'm worried about:
I think using these feature would break some browser support like IE11. |
@bgw I created xtermjs/xterm.js#1294 to track this, the issue I pointed to before xtermjs/xterm.js#1063 is a different set of optimizations that can be tackled separately. |
Why do you need IE 11 support @Tyriar Isn't performance more important than compatibility for xterm? 😄 Is there anyone using xterm in IE11? It was outdated 4 years ago |
@albinekb well it's more about developer convenience than performance, but IE11 support is needed to run xterm.js within Visual Studio 🙂 https://github.com/Microsoft/WhackWhackTerminal |
@bgw also are these different characters? Looks like 3 space chars? I notice 3 dark grey ones too? |
@Tyriar I need an ordered map implementation for the LRU cache, so I'm relying on the ES6 Map implementation, which guarantees insertion order iteration. We'll either need to pull in a polyfill, or I'll need to write a minimal ordered map implementation myself. Alternatively, we can try relying on the iteration order of objects in JS, but that's also a fairly new addition to the spec, though every major browser does implement it. Regarding the space characters: I use powerline, and that screenshot is from the demo page which doesn't use the right font, so I'm guessing it's just a couple of characters that didn't render quite right. The diff isn't ready for review yet, I just wanted to let people know that I'm working on it, so that nobody else starts to work on the same thing. |
Probably a polyfill is the way to go, we can tackle that later though.
Makes sense. Something else you might notice with the current implementation is that the default background color is pulled off of characters in the character atlas, this is so characters that are overlaid on wide glyphs will not completely override them. An example: We may just want to draw uncached for character that are on top of wide chars to avoid the bad antialiasing. As you can see wide characters are also something else to consider, let's try target just plan single width characters with this change initially before trying to cache wide ones 😄 |
FYI: Even with the dynamic char atlas patch set, drawing characters with a background is slower than without, since we make a new call to I'm hoping to tackle that problem next, but you might still want to stick with the EDIT: Oh, and let me know if you encounter any issues with the new atlas! |
@bgw Thank you so much for your hard work. This is totally amazing. Be sure, that we'll give you our feedback. |
FYI, xtermjs/xterm.js#1413 should negate the need for the |
Works around vercel/hyper#2592, which is a performance issue with xterm.js' character caching.
Issue
We have a huge perf regression with
xterm3
with a big/maximized window (usingvi
for example)xterm2 (2.0.0-canary.8)
xterm3 (2.0.0-canary.9)
Performance recording with xterm3
Try with last 1.8.2-beta.3 Electron version and no change.
I have same performance issue with VSCode
cc @Tyriar
The text was updated successfully, but these errors were encountered: