-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[release/10.0] [mono] Make the compressed interface bitmap feature usable #119953
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
[release/10.0] [mono] Make the compressed interface bitmap feature usable #119953
Conversation
…t#119694) * [mono][metadata] Enable compressed interface bitmap by default * Fix build on windows * Fix publishing of compressed bitmap Before this commit we were doing changes on the published data which is problematic for multithreaded environments. We ensure the bitmap is fully processed before publishing it so that we can rely on the data dependency memory ordering constraint for correctness.
…tmap feature (dotnet#119881) * Add option to configure use of compressed interface bitmaps This optimization is disabled by default. Enable it with `MONO_COMPRESSED_INTERFACE_BITMAP=1` * Add support for detecting mismatch with aot images
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 enables the compressed interface bitmap feature in Mono runtime by making it controllable via the environment variable MONO_COMPRESSED_INTERFACE_BITMAP
instead of requiring a compile-time definition. This optimization compresses the bitmap used to store implemented interfaces for classes, providing significant memory savings for applications with many types.
Key changes:
- Replaces compile-time
COMPRESSED_INTERFACE_BITMAP
define with runtimemono_opt_compressed_interface_bitmap
option - Adds environment variable
MONO_COMPRESSED_INTERFACE_BITMAP
support for enabling/disabling the feature - Updates AOT file format to track compressed interface bitmap usage
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/mono/mono/utils/options-def.h | Adds new boolean option for compressed interface bitmap feature |
src/mono/mono/mini/type-checking.c | Replaces compile-time conditional with runtime check for interface bitmap handling |
src/mono/mono/mini/mini-runtime.c | Updates icall registration to be conditional on runtime option |
src/mono/mono/mini/aot-runtime.h | Increments AOT file version and adds new flag for compressed interface bitmap |
src/mono/mono/mini/aot-runtime.c | Adds compatibility check between runtime option and AOT file flags |
src/mono/mono/mini/aot-compiler.c | Sets AOT flag when compressed interface bitmap is enabled |
src/mono/mono/metadata/metadata.c | Adds environment variable parsing to control the feature |
src/mono/mono/metadata/marshal.c | Replaces compile-time conditional with runtime check for stelemref optimization |
src/mono/mono/metadata/jit-icall-reg.h | Updates icall function name from generic to compressed-specific variant |
src/mono/mono/metadata/class-setup-vtable.c | Updates bitmap allocation and compression logic to use runtime option |
src/mono/mono/metadata/class-internals.h | Removes compile-time defines and updates interface matching macros |
src/mono/mono/metadata/class-init.c | Removes conditional compilation and renames interface match function |
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.
Aside from the two nits from Copilot, this looks good.
CC @jeffschwMSFT. |
All failures are tracked. Build analysis seems to have the wrong status. @jeffschwMSFT |
/ba-g failures are known |
When this option is enabled, the env var
MONO_COMPRESSED_INTERFACE_BITMAP=1
is passed, the bitmap that stores the set of implemented interfaces by a class is saved in a compressed format. This has significant memory improvement on applications using a lot of types.Customer Impact
This issue was discovered on a large customer application. The memory usage of these bitmaps was so big in this scenario that the application got killed by iOS.
Regression
The memory increase above the tipping point was caused by more types used after transitioning from xamarin to maui. However, this is not strictly a regression.
Testing
This was tested on the customer application. Also this new option was tested with our own set of tests.
Risk
Low. This feature is disabled by default so there shouldn't be any impact on existing applications. This PR adds the possibility to use this optimization, which was slightly bit-rotten and behind a compile time define before.