Repository navigation
Closed
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestResolution-FixedThe issue is fixed.The issue is fixed.Usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usabilityWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performancecore PowerShell engine, interpreter, and runtime performanceWG-Interactive-IntelliSensetab completiontab completion
Description
Steps to reproduce
Get a folder with a decent number of files (65k will do)
Try to do autocompletion on file name in this folder
Expected behavior
Respond time comparable with bash completion (about a second)
Actual behavior
No response for 12 seconds (appears like a hang)
For comparisons, ls | measure in the same folder takes about 4 seconds (3 times faster), which hints that there is a room for improvements even without a big rewrite for the completion logic.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.5
OS Darwin 16.7.0 Darwin Kernel Version 16.7.0: T...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0 Metadata
Metadata
Assignees
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestResolution-FixedThe issue is fixed.The issue is fixed.Usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usabilityWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performancecore PowerShell engine, interpreter, and runtime performanceWG-Interactive-IntelliSensetab completiontab completion
Activity
Scholars-Mate commentedon Feb 25, 2018
I looked into this a little and here's what I found. I used 65,000 empty files in a tmpfs on Debian Stretch. Tab completion in this directory took more than 16 seconds to complete. Pretty much all of the time spent during tab completion is focused in two places:
The globbing done here took around 25% of the time:
PowerShell/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Lines 4072 to 4077 in 16d7a62
Globbing in general seems to be slower than Bash. Running
Get-ChildItem *in PowerShell in the directory with 65,000 files takes around 12 seconds compared to less than a second for the Bash equivalent.The remaining 75% of the time is spent in this large loop:
PowerShell/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Lines 4215 to 4373 in 16d7a62
This flame graph, can give some insight into areas that could be improved. The most notable functions are
CompletionRequiresQuotes(),ExecuteCurrentPowerShell(),get_ProviderPath(), andNormalizeRelativePath(). Samuel Holland (@smaeul) and sergei (@vors) discussed how the provider path could be an easy target for optimization given that all of the results of the tab completion should share the same provider.vors commentedon Feb 25, 2018
Thank you Christopher Wong (@Scholars-Mate) for investigating this!
Here is a small glimpse into the flame graph, to encourage others to take a look at it
powercode commentedon Feb 26, 2018
There is a lot of work going on in .NET core in this area that we should get with the 2.1 release.
vors commentedon Feb 27, 2018
Staffan Gustafsson (@powercode) do you mean perf tools or performance work we will benefit from? Are we getting something for free in the new dotnet core?
powercode commentedon Feb 27, 2018
sergei (@vors) They are doing a ton of work regarding efficient file enumeration/projection, and a lot of getting
Span<T>based interfaces in place to reduce allocations. Looks very promising.I'm a bit involved in getting better abstractions for efficient regex's so we can make
Select-Stringfast.rjmholt commentedon Jul 18, 2018
Christopher Wong (@Scholars-Mate), sergei (@vors) do you remember how you created that flame graph? It would be really nice to reproduce that for other performance issues!
vors commentedon Jul 19, 2018
I think we followed this article http://blogs.microsoft.co.il/sasha/2017/02/27/profiling-a-net-core-application-on-linux/
There was not much customization, just make sure to run a debug build with symbols, so the names are populated.
rjmholt commentedon Jul 19, 2018
Oh awesome! Thanks sergei (@vors)!