Uh oh!
There was an error while loading. Please reload this page.
Reduce Unix Process.Start path resolution allocations - #132780
Conversation
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot address my feedback
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Addressed in Note AI/Copilot-generated response. |
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot it looks much better now. Please respond to my question
Uh oh!
There was an error while loading. Please reload this page.
adamsitnik
commented
Aug 26, 2026
@EgorBot -osx_arm64 -linux_x64 usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Engines;usingBenchmarkDotNet.Running;usingMicrosoft.Win32.SafeHandles;usingSystem;usingSystem.Diagnostics;usingSystem.IO;usingSystem.Text;usingSystem.Threading.Tasks;BenchmarkSwitcher.FromAssembly(typeof(DefaultEnvVars).Assembly).Run(args);[MemoryDiagnoser]publicclassDefaultEnvVars{privatestaticreadonlySafeFileHandles_nullHandle=File.OpenNullHandle();privatestaticProcessStartInfos_startProcessStartInfo=newProcessStartInfo(){FileName="whoami",// exists on both Windows and Unix, and has very short outputStandardInputHandle=s_nullHandle,StandardOutputHandle=s_nullHandle,StandardErrorHandle=s_nullHandle,};privateProcess?_startedProcess;[Benchmark]publicvoidStart()=>_startedProcess=Process.Start(s_startProcessStartInfo)!;[IterationCleanup(Target=nameof(Start))]publicvoidCleanupStart(){if(_startedProcess!=null){_startedProcess.WaitForExit();_startedProcess.Dispose();_startedProcess=null;}}[Benchmark]publicintRun()=>Process.Run(s_startProcessStartInfo).ExitCode;[GlobalCleanup]publicvoidCleanup()=>s_nullHandle.Dispose();} |
adamsitnik
commented
Aug 26, 2026
@copilot please invoke the code-review skill and post your analysis/results as a comment on this PR |
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Holistic ReviewMotivation: The code removes transient candidate-path strings from Unix executable lookup, a hot portion of Approach: The change uses Summary: Detailed Findings✅ Correctness — PATH fallback builder state
✅ Allocation strategy and API surfaceCandidate paths are composed in a stack-backed
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot please address the feedback where you have been tagged
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessUtils.Unix.cs:373
- Same issue as above:
using (pathBuilder)disposes a copy, which may not be the grown instance afterrefmutations, and suppressing CS0728 hides a potential pooled-buffer leak. Prefer ausingdeclaration on the local (or explicit try/finally) and avoid the extra nesting.
string? path = Environment.ProcessPath;
ValueStringBuilder pathBuilder = new(stackalloc char[256]);
#pragma warning disable CS0728 // pathBuilder is intentionally mutated via ref; disposal still targets this local
using (pathBuilder)
{
Uh oh!
There was an error while loading. Please reload this page.
This reverts commit 3fb7087. Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
adamsitnik
commented
Aug 31, 2026
/ba-g unrelated networking test failures |
Uh oh!
There was an error while loading. Please reload this page.
FindProgramInPathinto the Unix implementation.ValueStringBuilder; materialize strings only for successful matches.Benchmark results from EgorBot/Benchmarks#551: