-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
On Windows PowerShell, defer Add-Type until Set-ConsoleMode executed #638
Conversation
4de0624
to
3a27e74
Compare
…, do not set the console mode at all.PS Core, since the release of 6.0.0 has handled setting/resetting theconsole mode, so no need for posh-git to do this.This speeds up module import by ~.5 to .7 seconds on PSCore and by~150-200 msecs on Windows PowerShell.Fix #637
Keep this PR simple in scope - just the deferred Add-Type. After a chat w/lzybkr we may want to convert some of this to a binary to help import/prompt processing time.
Here's some profiling data. Current perf (without this PR):
Now with just deferring the Add-Type until first use - which happens to be in the first call to Write-VcsStatus which happens the first time the prompt function is called:
Now with not using Set-ConsoleMode on PS Core on Windows in a standard
One thing I've noted is there is a significant stddev in the GitTabExpansion processing time. I've seen it range from 136 up to 499 ms. That might be good place to look next for module import perf improvements. |
I've seen that not using set-consolemode within VSCode/s PS integrated console causes problems after executing git log --graph --decorate.
0a48392
to
78ad465
Compare
# On Windows, *if* we are running in PowerShell Core *and* the host is the "ConsoleHost", | ||
# rely on PS Core to manage the console mode. This speeds up module import on standard | ||
# PowerShell Core on Windows. | ||
if (($IsWindows -eq $false) -or (($PSVersionTable.PSVersion.Major -ge 6) -and ($host.Name -eq 'ConsoleHost'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a future extensibility point for other hosts that don't need Set-ConsoleMode
, but this is good for now.
when will this be available in the beta? |
I still have a few lingering PRs to catch up with, but I'll try to ship a new beta in the next week or so. |
So, uh. Beta 3 shipped yesterday. 🙄 |
{ | ||
$outputMode = [NativeConsoleMethods]::GetConsoleMode($false) | ||
$null = [NativeConsoleMethods]::SetConsoleMode($false, $outputMode -bor [ConsoleModeOutputFlags]::ENABLE_VIRTUAL_TERMINAL_PROCESSING) | ||
begin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rkeithhill What's the advantage of splitting this into begin
/end
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case, there is no advantage. Then again, there is no harm either. But I can simplify this if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change necessary unless you find the alternative easier to read. Just curious if I was missing something.
On PS Core, do not set the console mode at all.
PS Core, since the release of 6.0.0 has handled setting/resetting the
console mode, so no need for posh-git to do this. See:
PowerShell/PowerShell#2991
This speeds up module import by ~.5 to .7 seconds on PSCore and by
~150-200 msecs on Windows PowerShell.
Fix #637 and maybe #635