Description
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.
- a deeper call tree, which stops the changes introduced in JIT: allow some aggressive inlines to go over budget #38163 from helping
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