Maximus5 / ConEmu

Customizable Windows terminal with tabs, splits, quake-style, hotkeys and more
https://conemu.github.io/
BSD 3-Clause "New" or "Revised" License
8.53k stars 572 forks source link

Slow text-pasting #2378

Open mrx23dot opened 2 years ago

mrx23dot commented 2 years ago

What is the reason for pasting big text is still being slow? Looks like that's inherited from cmd.exe

Because on Putty linux terminal it's like 100x faster, even when it goes around the globe.

Test case: paste 10000 character without new line. CPU goes 100% for conemu.exe, and it takes 8000ms on i7, should be 1ms max. I would imagine we just collect in RAM buffer till enter comes.

Can we do some gcc profiling?

Latest release, default config win10

Maximus5 commented 2 years ago

It is by design.

Putty is able to write input directly to the socket. But ConEmu has to use WinAPI to fill console input buffer. If I write more data at once or at higher speed - characters loss will occur.

mrx23dot commented 2 years ago

Wow that's crazy :D

On win10 they look like fixed the issues and I can instantly paste 10 000 characters to cmd.exe, so at least we could make an exception for that.

I have to check on Win7.

Thinking about any scripting language (lua, python) would also use FillConsoleOutputCharacter and they don't wait for printing out.

Maximus5 commented 2 years ago

FillConsoleOutputCharacter is not about the Input, as the name says.

Maximus5 commented 2 years ago

https://docs.microsoft.com/en-us/windows/console/writeconsoleinput

mrx23dot commented 2 years ago

Here are a lot of solutions for speed up: https://stackoverflow.com/questions/5272177/console-writeline-slow

It's definitely worth trying each from the top.

e.g.: On my machine, this gets about 77,000 lines/second (mixed-length) versus only 5,200 lines/sec under identical conditions for normal Console.WriteLine. That's a factor of almost 15x speedup.

or If you want the fastest writes though, you'll need to make your own buffer class that writes to memory and flushes to the console asynchronously in the background using a single thread without locking.