-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Enable cached interface dispatch by default on non-JIT platforms #123776
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
|
@BrzVlad, this will require your scripts that call crossgen2 to use the right targetos switch. I believe @jkoritzinsky has made the behavior in the SDK work, but I don't know exactly what you're testing on now. |
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.
Pull request overview
This PR addresses a significant performance issue (200x slowdown) on iOS-like platforms where R2R virtual dispatch was falling back to expensive signature parsing on every call. The fix enables cached interface dispatch by default on platforms that don't support runtime code generation (JIT).
Changes:
- Changed the
--enable-cached-interface-dispatch-supportoption frombooltobool?to support platform-conditional defaults - Implemented default logic that enables cached interface dispatch on non-JIT platforms (iOS, iOSSimulator, tvOS, tvOSSimulator, MacCatalyst, WASM/WASI) while maintaining the existing
falsedefault on JIT-capable platforms - Updated help text to document the conditional default behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Crossgen2RootCommand.cs | Changed EnableCachedInterfaceDispatchSupport option type from bool to bool? to allow tristate values (true/false/unspecified) |
| Program.cs | Added conditional default logic using null-coalescing operator to enable cached interface dispatch when not explicitly set and platform doesn't support JIT |
| Resources.resx | Updated help text to document that the default is true on platforms which do not support runtime code generation |
Yes the SDK should be hooked up to pass the right target OS and arch. |
BrzVlad
left a comment
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.
Thanks, I'll validate that it works as expected once I have the .net11 P1 working with ios bits.
Description
R2R virtual dispatch on iOS-like platforms was falling back to
ExternalMethodFixupWorkeron every call instead of patching callsites, causing 200x slowdown in interface-heavy code. Profile showed 18% of time in signature parsing alone.Changes
--enable-cached-interface-dispatch-supportfrombooltobool?to support platform-conditional defaultstruewhenTargetAllowsRuntimeCodeGenerationis false (iOS, iOSSimulator, tvOS, tvOSSimulator, MacCatalyst, WASM)falseon JIT-capable platforms (existing behavior)Implementation
Crossgen2RootCommand.cs:
Program.cs:
User-specified values override the default on all platforms.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.