Skip to content

AggressiveInlining not respected when Method grow too large #41692

Closed
@HurricanKai

Description

@HurricanKai

Description

JIT will refuse to inline AggressiveInlining methods when Methods grow too large (IL size / too many branches, I'm unsure which one, but I expect IL size)
If I understand AggressiveInlining correctly, this is not intended.

This happened to me in a method like the below, but I've encountered it before:

public IntPtr Load(int slot) {
    if (slot == SLOT_ONE)
    {
         return _slotOne;
    }
    // x 1000 or so

    ThrowHelper();
    return default;
}

This does not inline/constant fold, leading to quite the performance hit since now all those comparisons are actual comparisons.
Splitting this into a binary tree of sorts has led to JIT inlining it, and a good performance increase.

Analysis

I think this can be related to #38106
I don't understand JIT very well, but I think this can have multiple causes.

It might be an idea to look for comparisons with constants that "end" the method and prioritize inlining? Looking at the inlinepolicy, which I think is where this kind of thing is decided, this would be difficult, but possible?

category:cq
theme:inlining
skill-level:intermediate
cost:medium

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions