petabridge/NBench

Linux: can't set processor affinity without being sudo in some environments

Aaronontheweb opened this issue · 1 comments

Ran into this here: akkadotnet/HOCON#236

Looks like

2020-02-24T21:44:58.2735223Z Starting Target: NBench (==> Build)
2020-02-24T21:44:58.2790788Z dotnet "run" "--no-build" "-c" "Release" " -- " "--output" "/home/vsts/work/1/s/PerfResults" "--concurrent" "true" "--trace" "true" "--diagnostic" 
2020-02-24T21:44:58.7141448Z DIAG: Executing with parameters [--trace true --concurrent true --output /home/vsts/work/1/s/PerfResults --diagnostic ]
2020-02-24T21:44:58.7148431Z DIAG: Unparsed arguments [/home/vsts/work/1/s/src/Hocon.Tests.Performance/bin/Release/netcoreapp2.1/Hocon.Tests.Performance.dll, -- ,--output,/home/vsts/work/1/s/PerfResults,--concurrent,true,--trace,true,--diagnostic]
2020-02-24T21:44:58.7215226Z DIAG: Captured, but unrecognized arguments: --output:[/home/vsts/work/1/s/PerfResults],--concurrent:[true],--trace:[true],--diagnostic:[]
2020-02-24T21:44:58.7308277Z 
2020-02-24T21:44:58.7472094Z Unhandled Exception: System.ComponentModel.Win32Exception: Permission denied
2020-02-24T21:44:58.7472917Z    at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
2020-02-24T21:44:58.7473593Z    at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
2020-02-24T21:44:58.7474197Z    at NBench.Sdk.TestRunner.SetProcessPriority(Boolean concurrent)
2020-02-24T21:44:58.7474646Z    at NBench.Sdk.TestRunner.Execute()
2020-02-24T21:44:58.7475093Z    at NBench.NBenchRunner.Run[TType]()
2020-02-24T21:44:58.7475749Z    at Hocon.Tests.Performance.Program.Main(String[] args) in /home/vsts/work/1/s/src/Hocon.Tests.Performance/Program.cs:line 9
2020-02-24T21:44:58.8733268Z Running build failed.
2020-02-24T21:44:58.8733871Z Error:

Need to make this check:

if (!IsMono)
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;

Work for Linux as a platform, not just Mono.