Up to 1 second delay in Windows 11 when launching console apps outside of terminal when Windows Terminal is set as default console host #11719
Labels
Area-Performance
Performance-related issue
Issue-Question
For questions or discussion
Product-Terminal
The new Windows Terminal.
Resolution-Answered
Related to questions that have been answered
Windows Terminal version (or Windows build number)
10.0.22000.0, 1.12.2931.0
Other Software
No response
Steps to reproduce
I have a win32 console subsystem application, which I normally run directly from a Powershell instance under Windows Terminal. It runs in about 40ms when I measure its running time with Measure-Command. I happened to be profiling this app with a third-party profiler (Superluminal) which made me notice it was spending about 1 second in the Ldr code that's responsible for loading the executable image (and its DLL dependencies).
Essentially all of that 1 second is spent blocked in the ConsoleInitialize call stack. I attached a screenshot so you can see for yourself.
I'm on Windows 11 and have Windows Terminal Preview (with the reported version number) set as my default terminal application. If I set the default terminal application back to Windows Console Host, the same Ldr code path only consumes 50ms instead of 1s.
Edit: I did an ETW trace which confirms that the console app is waiting on OpenConsole.exe -> WindowsTerminal.exe.
Edit: I did a bunch more traces and most of them take closer to 300 ms than 1 s. The lower end numbers are less egregious and I probably wouldn't have filed this issue if my initial measurements were in that lower range. In any case, I'll leave this issue here in case you think something here merits investigation.
Expected Behavior
Console applications should start up instantaneously even when launched from outside of terminal.
Actual Behavior
ConsoleInitialize code path takes ~1s to complete.
The text was updated successfully, but these errors were encountered: