Skip to content

GetThreadStaticsBase method is not included in R2R image #123616

Closed

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

Activity

  1. added this to the 11.0.0 milestone on Jan 26, 2026
  2. BrzVlad commented on Jan 26, 2026

    @BrzVlad
    MemberAuthor

    @davidwrighton Could you please give this a thought ?

  3. added a commit that references this issue on Jan 31, 2026
    1c57781
  4. locked and limited conversation to collaborators on Mar 2, 2026
  5. added a commit that references this issue on Mar 2, 2026
    a29766a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions