-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Issue 55685 processname optimisation #59672
Issue 55685 processname optimisation #59672
Conversation
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process Issue Detailsnull
|
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
Thanks for working on this. Can you share performance numbers? In particular, how does this impact the cost of a) iterating through every process and getting its name, and b) iterating through every process and getting both its name and its WorkingSet64? I ask because this is not only changing what Win32 function is used to get the process' name, it's also changing whether retrieving the name also retrieves other state. |
Very welcome! Good idea re. benchmarking. I'm happy to do this, although I think I would need some assistance. I'm somewhat familar with benchmarking, but I've been having difficulties consuming these changes from a standalone app outside the repo. |
@am11 / @stephentoub - are those failing checks a blocker? They don't look related to the changes in this PR. Also, are the benchmarks required before this PR can be approved? I won't have time to do them, but can do them in a week or so. |
Yes. The purpose of this PR is improving performance. That needs to be validated for this to be worthwhile churn, and it needs to validate that it doesn't regress other usage. Thanks. |
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
…k method of getting the process name
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
@stephentoub - here are the benchmarks as requested: BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000
Intel Core i7-7700K CPU 4.20GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.100-alpha.1.21467.19
[Host] : .NET 5.0.10 (5.0.1021.41214), X64 RyuJIT
Job-YJXSLY : .NET 7.0.0 (42.42.42.42424), X64 RyuJIT
Job-NVCLTE : .NET 7.0.0 (42.42.42.42424), X64 RyuJIT
IterationCount=15 LaunchCount=2 WarmupCount=10
|
Do I need to do anything else for this PR? I can see some of the checks have failed, but I don't think it's related to this code (but could be wrong) |
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.
Overall looks good, but we need to improve handling of the edge cases (please see my comments). Thank you for your contribution @SteveDunn !
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs
Outdated
Show resolved
Hide resolved
…rocessName.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
…rocessName.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
…s/Process.Unix.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
…s/Process.Windows.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
…s/Process.UnknownUnix.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
…s/ProcessManager.Windows.cs Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
|
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.
nit: extra empty line
} | |
} | |
|
||
if (_processName == null) | ||
{ | ||
throw new InvalidOperationException(SR.NoProcessInfo); |
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.
thank you for keeping the exception consistent with existing implementation! 👍
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessName.cs
Outdated
Show resolved
Hide resolved
…name-optimisation # Conflicts: # src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs
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.
LGTM, once again thank you @SteveDunn !
Fixes #55685.