-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Emit less jump-stubs on x64 #77639
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
Emit less jump-stubs on x64 #77639
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsFixes #77638, reduces number of jump stubs emitted from 44k to zero.
|
This comment was marked as outdated.
This comment was marked as outdated.
Did a couple of runs - with the current Main I always got 44k jump stubs in every single run of the benchmark. With this PR it's mostly 0, got 271 at some run. |
Hm.. however this PR might regress Managed-to-managed calls if both calls are not withing reach but next to each others. Probably still better than emitting jump-stubs for literally all VMs helpers such as allocators. So a better fix (as was on arm) is to rewrite Code manager to know the exact place in memory current code will be saved to. |
How does IIRC, this sequence consumed precious slots in call target predictor back in the day and going through jump stubs was faster in real workloads since it was better predicted. (Also, the smaller code helps too - instruction caches are often bottleneck in .NET workload since the code is too big.) |
984b13b
to
cebfced
Compare
@jkotas I've just pushed a change to limit this to Dynamic methods like you suggested in #62302 (comment) It lowers number of jump-stubs generated from 44k to ~4k every benchmark launch. However, it relies on a more precise |
Reminds me this issue on Apple M1: https://twitter.com/dougallj/status/1580826539205496832 🙂 |
I expect that it will regress small workloads with dynamic methods. The current scheme used by the JIT/EE interface is to assume that everything fits into Rel32. Once we hit one situation that does not fit, we will redo JITing of that method and stop returning I think it would be best to extend the current scheme to handle the dynamic jumpstub case. |
Isn't it a rare event and is not supposed to happen normally for small apps? |
Right, it is not supposed to happen for normal apps.
Right. I am suggesting to change the "a jump stub is emitted" part into "if it is a dynamic method { set a global flag that says to use inlinine call targets for dynamic methods and redo the method } else { a jump stub is emitted }". |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Fixes #77638, reduces number of jump stubs emitted from 44k to zero.
Codegen example for a method not within reloc32 reach:
where previously we emitted just a call to a jump-stub.