Runtime: Getting process information is few times slower on Linux

Created on 29 Oct 2019  路  11Comments  路  Source: dotnet/runtime

Getting process information is few times slower on Linux:

| Slower | Lin/Win | Win Median (ns) | Lin Median (ns) | Modality|
| -------------------------------------------------- | -------:| ---------------:| ---------------:| --------:|
| System.Diagnostics.Perf_Process.GetProcesses | 12.94 | 1048505.00 | 13562765.47 | |
| System.Diagnostics.Perf_Process.GetProcessesByName | 4.73 | 1059057.08 | 5010892.56 | |
| System.Diagnostics.Perf_Process.GetCurrentProcess | 4.49 | 101.52 | 455.68 | |

Important: System.Diagnostics.Perf_Process.GetProcesses fetches the data for all running processes and comparing two different OSes which run different number of processes is not apples-to-apples comparison. However, GetProcessesByName and GetCurrentProcess perform the same work and moreover GetCurrentProcess is frequently used API.

How to run the benchmarks:

git clone https://github.com/dotnet/performance.git
python3 ./performance/scripts/benchmarks_ci.py -f netcoreapp5.0 --filter 'System.Diagnostics.Perf_Process.Get*'

Recommended profilers are PerfCollect and VTune.

There is a high chance that we are already using the best available API and the limiting factor is OS here.

area-System.Diagnostics.Process tenet-performance

Most helpful comment

New PR would be best.

All 11 comments

Can I take this up as a part of https://github.com/dotnet/corefx/pull/41122 ? Or with a new PR ?

New PR would be best.

some relevant discussion: https://lwn.net/Articles/650243/
Reading /proc and parsing text is certainly not efficient.

@shubhamranjan I have assigned to you. thanks!

Thanks. I am already working on it.

How is it going @shubhamranjan ?

How is it going @shubhamranjan ?

Still working. Have done some minor changes. Struggling with creating a package on my system atm to benchmark it.

Cool!

Cool!

@danmosemsft I will unassign myself on this atm for others to give it a go as I am unable to dedicate time to it. Don't want to block this. However, if I am able to fix it I will raise a PR.

@shubhamranjan not a problem. Anyone else..

transferring so I can put it in the better for linux project.

Was this page helpful?
0 / 5 - 0 ratings