[release/10.0] [mono] Make the compressed interface bitmap feature usable#119953
Merged
agocke merged 2 commits intodotnet:release/10.0from Sep 22, 2025
Merged
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
Contributor
There was a problem hiding this comment.
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_BITMAPdefine with runtimemono_opt_compressed_interface_bitmapoption - Adds environment variable
MONO_COMPRESSED_INTERFACE_BITMAPsupport 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 |
vitek-karas
approved these changes
Sep 22, 2025
Member
vitek-karas
left a comment
There was a problem hiding this comment.
Aside from the two nits from Copilot, this looks good.
Member
|
CC @jeffschwMSFT. |
Member
Author
|
All failures are tracked. Build analysis seems to have the wrong status. @jeffschwMSFT |
Member
Author
|
/ba-g failures are known |
This was referenced Sep 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When this option is enabled, the env var
MONO_COMPRESSED_INTERFACE_BITMAP=1is 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.