@@ -4,8 +4,6 @@ namespace Runner.Jobs;
44
55internal sealed partial class BenchmarkLibrariesJob : JobBase
66{
7- private const string DotnetInstallDir = "dotnet-performance" ;
8-
97 public BenchmarkLibrariesJob ( HttpClient client , Dictionary < string , string > metadata ) : base ( client , metadata ) { }
108
119 protected override async Task RunJobCoreAsync ( )
@@ -32,7 +30,7 @@ protected override async Task RunJobCoreAsync()
3230 {
3331 await clonePerformanceTask ;
3432
35- PendingTasks . Enqueue ( DotnetHelpers . InstallDotnetDailySdkAsync ( this , GetPerformanceDotnetVersion ( ) , DotnetInstallDir ) ) ;
33+ PendingTasks . Enqueue ( DotnetHelpers . InstallDotnetSdkAsync ( this , "performance/global.json" ) ) ;
3634
3735 coreRuns = await DownloadCoreRootsAsync ( entries ) ;
3836 }
@@ -65,7 +63,7 @@ protected override async Task RunJobCoreAsync()
6563 await JitDiffJob . BuildAndCopyRuntimeBranchBitsAsync ( this , "pr" , uploadArtifacts : false , buildChecked : false , canSkipRebuild : false ) ;
6664 }
6765
68- await DotnetHelpers . InstallDotnetDailySdkAsync ( this , GetPerformanceDotnetVersion ( ) , DotnetInstallDir ) ;
66+ await DotnetHelpers . InstallDotnetSdkAsync ( this , "performance/global.json" ) ;
6967
7068 coreRuns = [ "artifacts-main/corerun" , "artifacts-pr/corerun" ] ;
7169 }
@@ -83,6 +81,13 @@ private async Task CloneDotnetPerformanceAndSetupToolsAsync()
8381
8482 await RunProcessAsync ( "git" , $ "clone --no-tags --depth=1 -b { branch } --progress https://github.com/{ repo } performance", logPrefix : "Clone performance" ) ;
8583
84+ if ( repo == "dotnet/performance" && branch == "main" )
85+ {
86+ // Performance's global.json is out of date
87+ byte [ ] bytes = await HttpClient . GetByteArrayAsync ( "https://raw.githubusercontent.com/dotnet/runtime/refs/heads/main/global.json" ) ;
88+ await File . WriteAllBytesAsync ( "performance/global.json" , bytes ) ;
89+ }
90+
8691 if ( TryGetFlag ( "medium" ) || TryGetFlag ( "long" ) )
8792 {
8893 string ? path = Directory . EnumerateFiles ( "performance" , "*.cs" , SearchOption . AllDirectories )
@@ -195,23 +200,6 @@ private async Task CloneDotnetPerformanceAndSetupToolsAsync()
195200 }
196201 }
197202
198- private int GetPerformanceDotnetVersion ( )
199- {
200- string source = File . ReadAllText ( "performance/src/benchmarks/micro/MicroBenchmarks.csproj" ) ;
201- // <SupportedTargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0;net11.0</SupportedTargetFrameworks>
202-
203- Match match = DotnetVersionFromCsprojRegex ( ) . Match ( source ) ;
204-
205- if ( ! match . Success )
206- {
207- throw new Exception ( "Failed to determine the dotnet version from MicroBenchmarks.csproj" ) ;
208- }
209-
210- // ["net6.0", "net7.0", ...]
211- string [ ] frameworks = match . Groups [ 1 ] . Value . Split ( ';' , StringSplitOptions . RemoveEmptyEntries ) ;
212- return frameworks . Max ( f => int . Parse ( f . AsSpan ( 3 , f . IndexOf ( '.' ) - 3 ) ) ) ;
213- }
214-
215203 private async Task < string [ ] > DownloadCoreRootsAsync ( CoreRootAPI . CoreRootEntry [ ] entries )
216204 {
217205 for ( int i = 0 ; i < entries . Length ; i ++ )
@@ -248,7 +236,7 @@ private async Task RunBenchmarksAsync(string[] coreRunPaths)
248236 filter = $ "*{ filter } *";
249237 }
250238
251- int dotnetVersion = GetPerformanceDotnetVersion ( ) ;
239+ int dotnetVersion = DotnetHelpers . GetDotnetVersion ( "performance" ) ;
252240
253241 string coreRuns = string . Join ( ' ' , coreRunPaths . Select ( p => $ "\" { Path . GetFullPath ( p ) } \" ") ) ;
254242
@@ -263,10 +251,8 @@ private async Task RunBenchmarksAsync(string[] coreRunPaths)
263251
264252 string ? artifactsDir = null ;
265253
266- string dotnetPath = Path . GetFullPath ( $ "{ DotnetInstallDir } /dotnet") ;
267-
268- await RunProcessAsync ( dotnetPath ,
269- $ "run -c Release --framework net{ dotnetVersion } .0 -- --cli \" { dotnetPath } \" --filter { filter } -h { HiddenColumns } --corerun { coreRuns } { parallelSuffix } ",
254+ await RunProcessAsync ( "/usr/lib/dotnet/dotnet" ,
255+ $ "run -c Release --framework net{ dotnetVersion } .0 -- --filter { filter } -h { HiddenColumns } --corerun { coreRuns } { parallelSuffix } ",
270256 workDir : "performance/src/benchmarks/micro" ,
271257 processLogs : line =>
272258 {
@@ -405,7 +391,4 @@ await RunProcessAsync(dotnetPath,
405391
406392 [ GeneratedRegex ( @"BenchmarkDotNet\.(\d.*?)\.nupkg" ) ]
407393 private static partial Regex BenchmarkDotNetPackageVersionRegex ( ) ;
408-
409- [ GeneratedRegex ( @"Frameworks>((?:net\d+\.\d+);?)+<\/" ) ]
410- private static partial Regex DotnetVersionFromCsprojRegex ( ) ;
411394}
0 commit comments