-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Milestone
Description
Thread static helpers were moved to managed code in https://github.com/dotnet/runtime/pull/108167/files. It seems GetThreadStaticsBase has a BypassReadyToRunAttribute as a workaround for some recursive dependency during initialization. On iOS this is relevant because every single thread static field access will now go through interpreter, which is much slower.
On the following microbenchmark, running in composite-r2r configuration with interpreter fallback (jit disabled) is 35x slower than default jit configuration.
using System;
using System.Runtime.CompilerServices;
using System.Threading;
public class Program {
[ThreadStatic]
private static int a;
[MethodImpl(MethodImplOptions.NoInlining)]
public static int GetA()
{
return a;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void SetA(int val)
{
a = val;
}
public static void Main(string[] args)
{
a = 1;
for (int i = 0; i < 500000000; i++)
SetA(GetA() + 1);
}
}
Reactions are currently unavailable