Enable GDV with multiple guesses for NativeAOT#87380
Conversation
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Unrelated: played with some jit opts and -Os mode to check size savings:
|
|
This is great! I'm not worried about the size hit, thanks for measuring! I assume 3 type checks means that if we have an interface that is implemented by 4 types, this would be covered (we generate 3 checks and a fallback to the last possible option). Just a general question - I'm not opposed to having this on the ILC side, but wouldn't it be better to have these defaults set on the RyuJIT side? We do pass SIZE_OPT to RyuJIT so it could also set the right default there. E.g. I wouldn't expect us to pass a |
Nope, if there are 4 impl and the MaxTypeChecks=3 we give up - it can be changed, the problem that we don't have probabilities here like with PGO, so we may end up expanding a call for 3 type checks which will never be taken as an app only uses the 4th one so we just add 3 type checks + lots of inlined code for them that is never executed.
No strong opinion on that, it's just that I want if (nativeAOT) I'll basically make it non-configurable from ILC args - if that's ok I can change |
|
|
@jkotas @MichalStrehovsky addressed |
Thanks! This looks great to me but it is a JIT change now and someone from the JIT team would be more qualified to sign off. |
|
I think we're seeing a 1.5% improvement in the Stage1 app with SizeOpts at https://aka.ms/aspnet/nativeaot/benchmarks: |
I am hoping to see improvements when we also enable GDV for interface calls where we don't inline them - currently we always give up on them. |
Ah, that would probably explain why this didn't help much without the speedopts - without tier-1 inlining budgets we likely give up often. |


I've tested the size impact on the Minimal API TodosApp:
(for reference, -Os is 27980)
Numbers are sizes (in KB) for differen values of
--codegenopt:JitGuardedDevirtualizationMaxTypeChecks=XSee #87055 for an example of what GDV with multiple guesses can do.
so
+84kbfor -O and+105kbfor -Ot (more aggressive inliner inlines more GDV guesses).We (@AndyAyersMS) think that 3 is the optimal number for number of guesses because e.g. 5 means that if the last guess is the correct one we'll pay an overhead of 4 type checks before we hit it and that can make it slower than just a virtual call.