@@ -82,15 +82,17 @@ public class AccurateSurvived
8282 public byte [ ] bytes64 ;
8383 public Task < int > task ;
8484
85- [ GlobalSetup ( Targets = new string [ ] { nameof ( EightBytesArrayNoAllocate ) , nameof ( SixtyFourBytesArrayNoAllocate ) } ) ]
85+ [ GlobalSetup ( Targets = new string [ ] { nameof ( EightBytesArrayNoAllocate ) , nameof ( SixtyFourBytesArrayNoAllocate ) , nameof ( TaskNoAllocate ) } ) ]
8686 public void SetupNoAllocate ( )
8787 {
8888 bytes8 = new byte [ 8 ] ;
8989 bytes64 = new byte [ 64 ] ;
90+ task = Task . FromResult ( default ( int ) ) ;
9091 }
9192
9293 [ Benchmark ] public byte [ ] EightBytesArrayNoAllocate ( ) => bytes8 ;
9394 [ Benchmark ] public byte [ ] SixtyFourBytesArrayNoAllocate ( ) => bytes64 ;
95+ [ Benchmark ] public Task < int > TaskNoAllocate ( ) => task ;
9496
9597
9698 [ Benchmark ] public void EightBytesArraySurvive ( ) => bytes8 = new byte [ 8 ] ;
@@ -118,6 +120,7 @@ public void MemoryDiagnoserSurvivedIsAccurate(IToolchain toolchain)
118120
119121 { nameof ( AccurateSurvived . EightBytesArrayNoAllocate ) , 0 } ,
120122 { nameof ( AccurateSurvived . SixtyFourBytesArrayNoAllocate ) , 0 } ,
123+ { nameof ( AccurateSurvived . TaskNoAllocate ) , 0 } ,
121124
122125 { nameof ( AccurateSurvived . EightBytesArraySurvive ) , 8 + objectAllocationOverhead + arraySizeOverhead } ,
123126 { nameof ( AccurateSurvived . SixtyFourBytesArraySurvive ) , 64 + objectAllocationOverhead + arraySizeOverhead } ,
@@ -401,9 +404,7 @@ private void AssertSurvived(IToolchain toolchain, Type benchmarkType, Dictionary
401404 {
402405 // Core has survived memory measurement problems.
403406 // See https://github.com/dotnet/runtime/issues/45446
404- if ( toolchain is CsProjCoreToolchain
405- || ( toolchain . IsInProcess && RuntimeInformation . IsNetCore )
406- || toolchain is CoreRtToolchain ) // CoreRt actually does measure accurately in a normal benchmark run, but doesn't with the specific version used in these tests.
407+ if ( toolchain is CsProjCoreToolchain || ( toolchain . IsInProcess && RuntimeInformation . IsNetCore ) )
407408 return ;
408409
409410 var config = CreateConfig ( toolchain , MemoryDiagnoser . WithSurvived ) ;
@@ -413,6 +414,11 @@ private void AssertSurvived(IToolchain toolchain, Type benchmarkType, Dictionary
413414
414415 foreach ( var benchmarkSurvivedValidator in benchmarkSurvivedValidators )
415416 {
417+ // CoreRT is missing some of the CoreCLR threading/task related perf improvements, so sizeof(Task<int>) calculated for CoreCLR < sizeof(Task<int>) on CoreRT
418+ // see https://github.com/dotnet/corert/issues/5705
419+ if ( benchmarkSurvivedValidator . Key == nameof ( AccurateSurvived . AllocateTaskSurvive ) && toolchain is CoreRtToolchain )
420+ continue ;
421+
416422 var survivedBenchmarks = benchmarks . BenchmarksCases . Where ( benchmark => benchmark . Descriptor . WorkloadMethodDisplayInfo == benchmarkSurvivedValidator . Key ) . ToArray ( ) ;
417423
418424 foreach ( var benchmark in survivedBenchmarks )
0 commit comments