Responsiveness regression in Windows Console Host #20154

Closed
opened 2026-01-31 07:05:16 +00:00 by claunia · 3 comments
Owner

Originally created by @averms on GitHub (Jun 27, 2023).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

1.17.11461.0

Windows Console Host version

1.17.2305.26001 (From right-click -> properties -> details)

Windows build number

10.0.19045.3086

Other Software

Typometer 1.1.0

Steps to reproduce

  1. On Windows 10, run conhost.exe and use typometer to measure the latency of a cmd prompt. I get an average of 16.3 ms with a standard deviation of 0.3 ms. Marvelous. See the first screenshot.
  2. Download the latest Windows Terminal zip and measure the latency of OpenConsole.exe. I get an average of 28.9 ms with a standard deviation of 7.2 ms. See the second screenshot.

image
image

Expected Behavior

I would like the new versions of conhost to have latency numbers closer to that of old conhost.

Actual Behavior

Latency in new versions of conhost is quite a bit worse.

Originally created by @averms on GitHub (Jun 27, 2023). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version 1.17.11461.0 ### Windows Console Host version 1.17.2305.26001 (From right-click -> properties -> details) ### Windows build number 10.0.19045.3086 ### Other Software [Typometer 1.1.0](https://github.com/frarees/typometer/releases/tag/v1.1.0) ### Steps to reproduce 1. On Windows 10, run `conhost.exe` and use typometer to measure the latency of a `cmd` prompt. I get an average of 16.3 ms with a standard deviation of 0.3 ms. Marvelous. See the first screenshot. 2. Download the latest Windows Terminal zip and measure the latency of `OpenConsole.exe`. I get an average of 28.9 ms with a standard deviation of 7.2 ms. See the second screenshot. ![image](https://github.com/microsoft/terminal/assets/29077900/81445d83-0748-4d74-a25b-438d30a0bd39) ![image](https://github.com/microsoft/terminal/assets/29077900/df2d981b-a8da-4ff7-95bf-4dfc5405ab50) ### Expected Behavior I would like the new versions of conhost to have latency numbers closer to that of old conhost. ### Actual Behavior Latency in new versions of conhost is quite a bit worse.
Author
Owner

@lhecker commented on GitHub (Jun 27, 2023):

FYI the trick to launch the application with JDK 17 is to use

java --add-opens=java.desktop/java.awt=ALL-UNNAMED -jar typometer-1.1.0.jar

Furthermore, the application only works if the display is set to 100% scale.


I could reproduce the issue immediately, although the latencies are 1 frame higher for me because I'm blessed with Windows 11. But the window borders are rounded so it's all good.

image

Fixing it is very simple, so I'll submit a PR shortly. Thanks for letting us know about this!

@lhecker commented on GitHub (Jun 27, 2023): FYI the trick to launch the application with JDK 17 is to use ``` java --add-opens=java.desktop/java.awt=ALL-UNNAMED -jar typometer-1.1.0.jar ``` Furthermore, the application only works if the display is set to 100% scale. --- I could reproduce the issue immediately, although the latencies are 1 frame higher for me because I'm blessed with Windows 11. But the window borders are rounded so it's all good. ![image](https://github.com/microsoft/terminal/assets/2256941/084dee56-bbb7-45e4-8a5f-84e414bb4383) Fixing it is very simple, so I'll submit a PR shortly. Thanks for letting us know about this!
Author
Owner

@elsaco commented on GitHub (Jun 28, 2023):

Building with 72b44888 when maximizing the terminal window latency is worse:

wt-dev-latency

Tests 4 and 5 were done with the patch applied. Test 4 was maximized window, and test 5 was full screen. Test 1 was done with terminal 1.18.1462.0. All test were done on Windows 10.

@elsaco commented on GitHub (Jun 28, 2023): Building with 72b44888 when maximizing the terminal window latency is worse: ![wt-dev-latency](https://github.com/microsoft/terminal/assets/3933920/540fded7-41b6-42a4-8e6d-a443ef7abf55) Tests 4 and 5 were done with the patch applied. Test 4 was maximized window, and test 5 was full screen. Test 1 was done with terminal 1.18.1462.0. All test were done on Windows 10.
Author
Owner

@lhecker commented on GitHub (Jun 28, 2023):

@elsaco You built Windows Terminal in debug mode right? Try building it in release mode:
image

It's one of the many remaining performance issues ("inoptimalities"?) in Windows Terminal. We use std::regex to scan for URLs in the viewport to make them clickable. The larger the viewport the longer that takes. It's a bit hilarious that it takes ~150ms to scan through 40kB of text in a debug build, but oh well. My hope is to replace it with ICU in the near term which has a much more efficient regex implementation. In release builds it is 40x faster and in debug builds somewhere around 1700x faster. In a release build it reduces the CPU cost for URL scanning from about 64ms CPU time per second down to ~1.5ms per second, which is still way too much, but not terribly so. (In a debug build it reduces it down from "actively lagging because it needs more seconds of CPU than there are seconds in a second", as we can see in the screenshots above. 😄)

@lhecker commented on GitHub (Jun 28, 2023): @elsaco You built Windows Terminal in debug mode right? Try building it in release mode: ![image](https://github.com/microsoft/terminal/assets/2256941/5b0eae70-f609-4ca6-a30e-50e6c90d50e1) It's one of the many remaining performance issues ("inoptimalities"?) in Windows Terminal. We use `std::regex` to scan for URLs in the viewport to make them clickable. The larger the viewport the longer that takes. It's a bit hilarious that it takes ~150ms to scan through 40kB of text in a debug build, but oh well. My hope is to replace it with ICU in the near term which has a much more efficient regex implementation. In release builds it is 40x faster and in debug builds somewhere around 1700x faster. In a release build it reduces the CPU cost for URL scanning from about 64ms CPU time per second down to ~1.5ms per second, which is still way too much, but not terribly so. (In a debug build it reduces it down from "actively lagging because it needs more seconds of CPU than there are seconds in a second", as we can see in the screenshots above. 😄)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20154