@@ -125,18 +125,18 @@ public static bool TrySetAffinity(
125125 internal static void SetEnvironmentVariables ( this ProcessStartInfo start , BenchmarkCase benchmarkCase , IResolver resolver )
126126 {
127127 if ( benchmarkCase . Job . Environment . Runtime is ClrRuntime clrRuntime && ! string . IsNullOrEmpty ( clrRuntime . Version ) )
128- start . EnvironmentVariables [ "COMPLUS_Version" ] = clrRuntime . Version ;
128+ SetClrEnvironmentVariables ( start , "Version" , clrRuntime . Version ) ;
129129
130130 if ( benchmarkCase . Job . Environment . Runtime is MonoRuntime monoRuntime && ! string . IsNullOrEmpty ( monoRuntime . MonoBclPath ) )
131131 start . EnvironmentVariables [ "MONO_PATH" ] = monoRuntime . MonoBclPath ;
132132
133133 if ( benchmarkCase . Config . HasPerfCollectProfiler ( ) )
134134 {
135135 // enable tracing configuration inside of CoreCLR (https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/linux-performance-tracing.md#collecting-a-trace)
136- start . EnvironmentVariables [ "COMPlus_PerfMapEnabled" ] = "1" ;
137- start . EnvironmentVariables [ "COMPlus_EnableEventLog" ] = "1" ;
136+ SetClrEnvironmentVariables ( start , "PerfMapEnabled" , "1" ) ;
137+ SetClrEnvironmentVariables ( start , "EnableEventLog" , "1" ) ;
138138 // enable BDN Event Source (https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/linux-performance-tracing.md#filtering)
139- start . EnvironmentVariables [ "COMPlus_EventSourceFilter" ] = EngineEventSource . SourceName ;
139+ SetClrEnvironmentVariables ( start , "EventSourceFilter" , EngineEventSource . SourceName ) ;
140140 // workaround for https://github.com/dotnet/runtime/issues/71786, will be solved by next perf version
141141 start . EnvironmentVariables [ "DOTNET_EnableWriteXorExecute" ] = "0" ;
142142 }
@@ -258,21 +258,27 @@ private static void SetCoreRunEnvironmentVariables(this ProcessStartInfo start,
258258 {
259259 var gcMode = benchmarkCase . Job . Environment . Gc ;
260260
261- start . EnvironmentVariables [ "COMPlus_gcServer" ] = gcMode . ResolveValue ( GcMode . ServerCharacteristic , resolver ) ? "1" : "0" ;
262- start . EnvironmentVariables [ "COMPlus_gcConcurrent" ] = gcMode . ResolveValue ( GcMode . ConcurrentCharacteristic , resolver ) ? "1" : "0" ;
261+ SetClrEnvironmentVariables ( start , "gcServer" , gcMode . ResolveValue ( GcMode . ServerCharacteristic , resolver ) ? "1" : "0" ) ;
262+ SetClrEnvironmentVariables ( start , "gcConcurrent" , gcMode . ResolveValue ( GcMode . ConcurrentCharacteristic , resolver ) ? "1" : "0" ) ;
263263
264264 if ( gcMode . HasValue ( GcMode . CpuGroupsCharacteristic ) )
265- start . EnvironmentVariables [ "COMPlus_GCCpuGroup" ] = gcMode . ResolveValue ( GcMode . CpuGroupsCharacteristic , resolver ) ? "1" : "0" ;
265+ SetClrEnvironmentVariables ( start , "GCCpuGroup" , gcMode . ResolveValue ( GcMode . CpuGroupsCharacteristic , resolver ) ? "1" : "0" ) ;
266266 if ( gcMode . HasValue ( GcMode . AllowVeryLargeObjectsCharacteristic ) )
267- start . EnvironmentVariables [ "COMPlus_gcAllowVeryLargeObjects" ] = gcMode . ResolveValue ( GcMode . AllowVeryLargeObjectsCharacteristic , resolver ) ? "1" : "0" ;
267+ SetClrEnvironmentVariables ( start , "gcAllowVeryLargeObjects" , gcMode . ResolveValue ( GcMode . AllowVeryLargeObjectsCharacteristic , resolver ) ? "1" : "0" ) ;
268268 if ( gcMode . HasValue ( GcMode . RetainVmCharacteristic ) )
269- start . EnvironmentVariables [ "COMPlus_GCRetainVM" ] = gcMode . ResolveValue ( GcMode . RetainVmCharacteristic , resolver ) ? "1" : "0" ;
269+ SetClrEnvironmentVariables ( start , "GCRetainVM" , gcMode . ResolveValue ( GcMode . RetainVmCharacteristic , resolver ) ? "1" : "0" ) ;
270270 if ( gcMode . HasValue ( GcMode . NoAffinitizeCharacteristic ) )
271- start . EnvironmentVariables [ "COMPlus_GCNoAffinitize" ] = gcMode . ResolveValue ( GcMode . NoAffinitizeCharacteristic , resolver ) ? "1" : "0" ;
271+ SetClrEnvironmentVariables ( start , "GCNoAffinitize" , gcMode . ResolveValue ( GcMode . NoAffinitizeCharacteristic , resolver ) ? "1" : "0" ) ;
272272 if ( gcMode . HasValue ( GcMode . HeapAffinitizeMaskCharacteristic ) )
273- start . EnvironmentVariables [ "COMPlus_GCHeapAffinitizeMask" ] = gcMode . HeapAffinitizeMask . ToString ( "X" ) ;
273+ SetClrEnvironmentVariables ( start , "GCHeapAffinitizeMask" , gcMode . HeapAffinitizeMask . ToString ( "X" ) ) ;
274274 if ( gcMode . HasValue ( GcMode . HeapCountCharacteristic ) )
275- start . EnvironmentVariables [ "COMPlus_GCHeapCount" ] = gcMode . HeapCount . ToString ( "X" ) ;
275+ SetClrEnvironmentVariables ( start , "GCHeapCount" , gcMode . HeapCount . ToString ( "X" ) ) ;
276+ }
277+
278+ private static void SetClrEnvironmentVariables ( ProcessStartInfo start , string suffix , string value )
279+ {
280+ start . EnvironmentVariables [ $ "DOTNET_{ suffix } "] = value ;
281+ start . EnvironmentVariables [ $ "COMPlus_{ suffix } "] = value ;
276282 }
277283 }
278284}
0 commit comments