Skip to content

Commit f642a02

Browse files
committed
Delete clrjit backup files after jitdiff runs
1 parent 9faa161 commit f642a02

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

Runner/Helpers/JitDiffUtils.cs

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,37 @@ private static async Task RunJitDiffAsync(JobBase job, string coreRootFolder, st
9797
envVars.Add(("DOTNET_DisableOptimizedThreadStaticAccess", "1"));
9898
}
9999

100-
await job.RunProcessAsync("jitutils/bin/jit-diff",
101-
$"diff " +
102-
(debugInfo ? "--debuginfo " : "") +
103-
(verbose ? "--verbose " : "") +
104-
(useCctors ? "--cctors " : "") +
105-
(useTier0 ? "--tier0 " : "") +
106-
(gcInfo ? "--gcinfo " : "") +
107-
(sequential ? "--sequential " : "") +
108-
$"--output {outputFolder} " +
109-
$"{frameworksOrAssembly} --pmi " +
110-
$"--core_root {coreRootFolder} " +
111-
$"--base {checkedClrFolder}",
112-
logPrefix: $"jit-diff {logPrefix ?? coreRootFolder}",
113-
envVars: envVars,
114-
cancellationToken: cancellationToken);
100+
try
101+
{
102+
await job.RunProcessAsync("jitutils/bin/jit-diff",
103+
$"diff " +
104+
(debugInfo ? "--debuginfo " : "") +
105+
(verbose ? "--verbose " : "") +
106+
(useCctors ? "--cctors " : "") +
107+
(useTier0 ? "--tier0 " : "") +
108+
(gcInfo ? "--gcinfo " : "") +
109+
(sequential ? "--sequential " : "") +
110+
$"--output {outputFolder} " +
111+
$"{frameworksOrAssembly} --pmi " +
112+
$"--core_root {coreRootFolder} " +
113+
$"--base {checkedClrFolder}",
114+
logPrefix: $"jit-diff {logPrefix ?? coreRootFolder}",
115+
envVars: envVars,
116+
cancellationToken: cancellationToken);
117+
}
118+
finally
119+
{
120+
// jit-diff backs up the core_root's JIT to 'backup-<jit>' before swapping in the base/diff JIT
121+
// and restores from it afterwards, but never deletes the backup. Delete it: a leftover backup
122+
// in a shared core_root would be hard-linked into every parallel worker's clone by
123+
// CreateCoreRootCloneForJitDiff, and concurrent jit-diff File.Copy writes onto that single
124+
// shared inode collide with "the file is being used by another process" on Linux.
125+
foreach (string jitName in s_jitDiffMutatedCoreRootFiles)
126+
{
127+
try { File.Delete(Path.Combine(coreRootFolder, $"backup-{jitName}")); }
128+
catch { }
129+
}
130+
}
115131
}
116132

117133
public static async Task<string> RunJitAnalyzeAsync(JobBase job, string mainDirectory, string prDirectory, int count = 100)

0 commit comments

Comments
 (0)