microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.28k stars 8.27k forks source link

conpty exhibits pathological performance on scrolling region redraw (repaints entire screen) #7019

Closed izghitu closed 1 year ago

izghitu commented 4 years ago

Environment

Windows build number: Win32NT             10.0.18362.0 Microsoft Windows NT 10.0.18362.0
Windows Terminal version (if applicable): latest

Steps to reproduce

ssh into a remote host, execute a command that spits a lot of output

Expected behavior

In putty when the connection to a remote host is slow and a command spits a lot of output and that output comes back in frames(due to the slow connection) then I can just fine switch between SCREEN tabs. In windows terminal this is not possible. I am not even able to switch between tabs of the windows terminal until the command previous executed does not finish its output.

Actual behavior

Need to wait for full command output before I can do anything else in the windows terminal.

jblaine commented 4 years ago

@izghitu I believe your report is a duplicate of https://github.com/microsoft/terminal/issues/6258 which is specifically about Ctrl-C but I am sure that same situation applies to any control sequence, like those used in GNU screen.

zadjii-msft commented 4 years ago

@izghitu Which ssh are you using? The ssh.exe that ships with Windows, or one from WSL (or some other one)? And which version?

Also latest doesn't really help as a version number, because at the time of your post, latest could have either meant 1.0, 1.1, or 1.2, depending if you were on the preview or release builds, and if you had gotten the release that shipped on the 22nd. Which WT version number exactly?

@jblaine this doesn't really sound like it's related to Ctrl+C to me at all. Here OP is just trying to switch tabs in screen, which isn't working (and is reasonable if the output is being heavily buffered), nor is switching Terminal tabs (which is really quite surprising)

izghitu commented 4 years ago

@zadjii-msft I use the ssh.exe that ships with WIndows. Its location is:

C:\\Windows\\System32\\OpenSSH\\ssh.exe

The version of the WT is Version: 1.1.2021.0

zadjii-msft commented 4 years ago

Some other questions from #7191:

jblaine commented 4 years ago

@zadjii-msft My hour of testing showed the following for what I'm experiencing.

Windows build number: Microsoft Windows [Version 10.0.18363.959] Windows Terminal version (if applicable): 1.1.2021.0

Windows 10 native ssh client Remote Linux host running either tmux or GNU screen, multiple versions all work to reproduce issue

Connect via Windows 10 ssh (under Terminal) to a remote host. At the remote host, run a new screen or tmux session OR re-attach to an existing one. Generate a lot of output from a shell in one of the screen or tmux windows. Terminal crawls in batches of text displayed and often becomes unresponsive for periods of time. In my particular case, I am using a Terminal profile with commandLine of "ssh <my args>"

The same behavior can be seen in a WSL distro using the distro's SSH connected to the remote host + attach to screen + cat big file.

It does not happen when running a bare CMD.EXE (outside of Terminal) and then wsl.exe ssh.exe <args to ssh...> + screen resume + cat big file.

After digging around in the open issues here and finding some other issue about slow rendering when colors are at play, I even tested when TERM=vt100 on the remote end and all coloring turned off. The performance issue still exists in that case, so it does not seem to have to do anything with that other color perf. issue.

zadjii-msft commented 4 years ago

It does not happen when running a bare CMD.EXE (outside of Terminal) and then wsl.exe ssh.exe <args to ssh...> + screen resume + cat big file.

Well that pretty specifically rules out a whole bunch of possible sources of this issue actually. That narrows it down to specifically the Terminal, and rules out conpty, ssh.exe, and screen as possible sources of error.

That being said, I wonder what about the terminal is causing the stuttering. XAML? DX? Scrollbar updating?

Does setting "historySize":0 in your profile help at all? That'll disable scrollback, but might help narrow it down further.

There are also a pair of global renderer settings that might be able to help rule out DX. Does setting either of these to true in the global settings (outside of a profile) change anything?

jblaine commented 4 years ago

No, none of those helped.

lucastheisen commented 4 years ago

Not sure how related this is to this exact issue, but output seems rather slow in general. I was working to confirm @jblaine 's findings and tried this quick benchmark from 3 different terminals: time bash -c "for i in {1..1000000}; do echo \$i; done;" It shows an order of magnitude slowdown for this terminal:

microsoft terminal:

real    2m53.944s
user    0m15.734s
sys     0m33.375s

wsltty:

real    0m25.828s
user    0m7.188s
sys     0m6.781s

mobaxterm:

real    0m29.078s
user    0m4.203s
sys     0m5.219s

But figured it might help narrow down a cause...

zadjii-msft commented 4 years ago

@lucastheisen That's actually something we're dealing with primarily over in #3075, but also in a bunch of different places. I'd keep an eye on that one πŸ˜‰

ghost commented 4 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

jblaine commented 4 years ago

This should be reopened, please

DHowett commented 4 years ago

Thanks. Our bot should be taught to recognize any commenter who can provide additional information.

One more question - are you using a status line in screen or tmux?

jblaine commented 4 years ago

Thanks @DHowett. Yes, I do use a statusline in screen. My tmux testing was only for this issue. I don't use tmux in my daily life.

DHowett commented 4 years ago

Okay, excellent. Thanks.

We have a pathological redraw case when there are sub-full-screen scrolling regions active (like, where there’s a status line). We end up retransmitting the entire contents of the screen for every line between the backend and frontend processes in Terminal. The contention on the output queue bogs down the input queue.

DHowett commented 4 years ago

I believe we have another version of this lying around somewhere, so I’ll assign myself to deduplicate.

zadjii-msft commented 3 years ago

Just messaged Dustin about this - turns out there's not another dupe for this one! This is now the tracking thread for this issue. Thanks!

zadjii-msft commented 2 years ago

Wait this might actually be #5228 after all. Or, at least, should be tracked as part of it. @DHowett back me up?

zadjii-msft commented 1 year ago

I'm pretty sure this is /dup #%228 after all.