-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mono][inline] Allow inlining methods containing ctor calls if they h… #84660
Conversation
…ave the aggressive inlining flag. Re: dotnet/perf-autofiling-issues#15660.
if (!m_method_is_aggressive_inlining (cfg->current_method) && !m_method_is_aggressive_inlining (cmethod)) | ||
INLINE_FAILURE ("ctor call"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vargaz, why only if they are marked aggressive inlining rather than in general based on the same heuristics as other methods?
There are a lot of methods that are small and call constructors or other things that aren't marked this way that would benefit.
Consider for example op_Explicit
and op_Implicit
cast operators that are implemented simply as:
public static implicit operator BigInteger(byte value) => new BigInteger(value);
We likewise have constructors that defer to other constructors and similar where many of these are very small methods that basically just forward to others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mono inlining heuristics are not very good, this PR just fixes an issue where inlining was disabled even through the callee had the aggressive inlining flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue tracking Mono improving these heuristics?
We (the libraries team) don't typically put AggressiveInlining
on small methods, particularly methods <= 16 bytes of IL
-- This is the "always inline threshold" for RyuJIT, barring cases like PGO or the method always throwing, which would indicate its a likely cold path.
We instead tend to only put it on methods which are known to be extra hot or known to be problematic for the JIT, such as having a large amount of code that can be elided as part of dead code optimizations, generic specialization, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(so this may be a general place where Mono could see some easy perf wins by adjusting its heuristics and becoming more similar to what RyuJIT is doing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its possible. In this particular case, INLINE_FAILURE means we abort inlining the current method if it makes a call to a ctor.
…ave the aggressive inlining flag.
Re: dotnet/perf-autofiling-issues#15660.