-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Reload environment variables only on WM_SETTINGCHANGE #15102
Comments
@lhecker some people in the winget comments thread seem to think that microsoft/terminal should be responsible for refreshing the environment variables after a program is installed through winget. I'm highly skeptical of this claim, and it sounds backwards to me, but could we emit a WM_SETTINGCHANGE from winget to refresh the env variables after this is merged? Thanks! |
Since #14999 we already get the latest environment variables whenever you create a new tab or pane. But In short, we cannot refresh the variables of another process, like the shell for instance. While overwriting the environment stored in This issue is just about how #14999 took a large shortcut and burns dozens of millions of cycles during startup (and every time you open a tab), because it reconstructs the environment variables every time without caching. I want it to only do that when we receive a |
Thank you for all the information, that was very helpful! |
@lhecker, if I understand correctly:
Am I understanding correctly? |
Yep, that's correct. |
What's the order of magnitude of the time added by #14999 when opening a new tab? |
That heavily depends on whether you have animations enabled in Windows or not (and which ones). WinUI's animations are an extreme resource hog. From what I can tell it's about 1.5-3% if they're enabled and about 5-10% if disabled, edit: relative to the total CPU cost inside WindowsTerminal.exe. |
For folks who maybe got confused like I did: Reloading env vars takes the same number of cycles regardless of whether animations are enabled or not. Opening tabs with animations enabled takes more CPU cycles than without, so the impact of env vars is relatively less. |
Thanks for the clarification! |
til::env
is rather complex, reads a lot of registry keys and requires lots of string operations. Since #14999 we recreate thetil::env
cache every time we create a new tab, but this isn't necessary, considering that changes to environment variables are exceedingly rare. Most users will run a Windows Terminal instance without it ever seeing a single environment variable change.👉 Listen to
WM_SETTINGCHANGE
and only then recreate the globally shared cache. If multi-threading is a concern, just encode the variables back into a\0
separated string, the same way we get it from the OS anyways already. This would reflect how ConEmu does it: Maximus5/ConEmu#468The text was updated successfully, but these errors were encountered: