-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Poor performance when terminal+canvas renderer is on a very wide container #4175
Comments
Without using the fitAddon and just resizing it manually, it seems to start degrading after I set to 2500 cols. |
2500 cols? 😱 Not sure where to start here - maybe lets make it blunt: this sort of perf degradation is kinda to be expected with canvas renderer for very huge displays. Reasons: I am really interested in some perf diagnostics on such a big display. Care to run the demo in chrome and make some screenshots from the devtools->profiler tab? (Similar to these: #4112) Also the difference canvas to webgl would be interesting. @Tyriar I wonder if there is a BG drawing bottleneck somewhere? This sounds suspicious:
I also wonder if we'd get some speedup by doing more double buffering (e.g. on line level before placing it on target canvas). |
Hi @jerch thanks for the fantastic explanation. Here's the minimum repro I used: https://github.com/goenning/xterm-cols-repro/blob/main/main.js xterm-addon-canvasWith 1000 cols, pretty much no activity But with 2000, we seem to be spending a lot of time on the for each cell loop And this is noticeable on the UI. When I change from 1500 to 2000 it becomes unusable. I'm on a Macbook M1 Pro btw Note 1: There's this on the console xterm-addon-webglI also tried webgl, performance looks great even with 3000 cols, but the text gets blurry/stretched. Everything is fine with rendering up until ~2000 cols, but starts having issues with rendering at that stage, it becomes worse as the col size increases. Regarding the use caseIt's a logging viewer, so it's impossible to know how wide the log lines will be. I understand 2500 is a lot and I guess most users are unlikely to scroll that much. Is there a way to force xterm to crop at a certain col and avoid breaking into another line? |
Hmm thats interesting, xterm.js does not do anything different for different col sizes, maybe thats some sort of cache thrashing in the browser/JS engine? Do other browser engines (webkit/Firefox) show a similar behavior? (Its alot harder to get nice profiling data on those, maybe you are still able to spot it from "interactiveness"?) On a sidenote: From tests in the image addon I remember that Edit:
Not really, as the print action is not hookable. There are tricks possible like disabling DECAWM, which would avoid auto-wrap writing all excess chars into the last cell of a row. Not sure if thats good enough for you. Another idea would be to preprocess the data with a headless xterm.js instance, and to cut off the excess chars. But thats quite involved to get done. |
We haven't really optimized the renderers for that large, in my brief experience looking at this I think we run into problems with maximum texture when it is (eg. the stretching webgl texture). It may also be slow simply because we're iterating over all columns, not just the line length here: Remember though that the canvas renderer should be a fallback for the webgl renderer, which is superior in pretty much every way. I think it's most useful to instead fix the webgl renderer's stretching problem here. Something I looked into recently was bringing the webgl renderer to the monaco text editor (microsoft/vscode#162445) which requires supporting both partially scrolled lines as well as very long non-wrapping lines. Instead of sizing the canvas to the number of columns, the best thing to do here is to size it to the viewport on screen and only render what's actually on screen. We'd need to change how xterm.js works wrt element size/horizontal scrolling, but we could do very long rows by adding an x offset uniform and then only draw from there. As is done in my prototype to accomplish partial lines with the y offset, we'd add an xoffset uniform to allow partial line rendering (clipped cells on the left/right), and then only draw viewport |
@jerch i haven’t checked Firefox yet, but I’ve seen the same behaviour on Safari. It’s usable at 1500, and becomes unresponsive at 2000 cols @Tyriar performance on webgl is fantastic, that’s definitely the one ill be starting with. Is the stretching a known bug? Or should I open a separate one for it. |
@goenning I don't think it's tracked outside of my head yet 😉, yes please create an issue. That should also make CPU usage much lower for webgl by only rendering what's on screen |
Details
Steps to reproduce
Note: This is somehow related to #2544
While it's understandable how horizontal scrolling is outside scope of xterm, is there anything that can be done to make it usable on a very wide container?
This is especially useful for viewing logs.
Thanks
The text was updated successfully, but these errors were encountered: