Skip to content

Tiered JIT: redundant compilations #76402

@EgorBo

Description

@EgorBo

To record @AndyAyersMS's thoughts I came up with a quick repro:

public class Program
{
    public static void Main()
    {
        for (int i = 0; i < 100; i++)
        {
            // Promote Test to Tier1
            Test();
            Thread.Sleep(16);
        }
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static int Test()
    {
        return Property;
    }

    private static int Property => 42;
}

Run this code with DOTNET_JitDisasmSummary=1 on .NET 7.0 RC1 and it's going to print:

   ...
   4: JIT compiled Program:Main() [Tier0, IL size=27, code size=94]
   5: JIT compiled Program:Test():int [Tier0, IL size=6, code size=23]
   6: JIT compiled Program:get_Property():int [Tier0, IL size=3, code size=11]
   7: JIT compiled Program:Test():int [Tier1, IL size=6, code size=6]
   8: JIT compiled Program:get_Property():int [Tier1, IL size=3, code size=6]

get_Property was compiled twice (Tier0 and Tier1) despite the fact it's super trivial (like e.g. any auto-property) - only 6 bytes of IL and we wasted some time on it.

We should consider allowing inlining for very small methods in Tier0, potentially, this might even improve JIT's TP because call IR nodes are slow to process. Only if they're small and don't contain control-flow

category:cq
theme:tiering
skill-level:expert
cost:large
impact:medium

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions