Skip to content

GetThreadStaticsBase method is not included in R2R image #123616

@BrzVlad

Description

@BrzVlad

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);
    }
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions