-
Notifications
You must be signed in to change notification settings - Fork 553
[native] Generate less relocations in libxamarin-app.so #10195
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
Conversation
e282048
to
313476d
Compare
Instead of separate per-assembly buffers, there's now a single buffer and assembly descriptors use offsets into this buffer to store data. This removes N + 1 relocs where N is the number of assemblies in the app. The extra removed relocation is for the pointer which used to point to the descriptors array, which is now made public. MonoVM runtime not yet updated.
Eliminates N*2 relocations
Eliminates N*2 relocations
313476d
to
d0a23d4
Compare
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 refactors how bundled assemblies, DSO names, environment variables, and runtime properties are represented in the native and CLR stubs—moving from pointer-based structures to index-and-blob layouts to reduce relocations in libxamarin-app.so
.
- Replace
CompressedAssemblies
pointer fields with separate count, descriptors array, and contiguous data buffer with offsets. - Mirror these changes in the CLR stub and update all decompression logic to use buffer offsets plus bounds checks.
- Update MSBuild native-assembly generators to emit the new index/blobs for assemblies, DSO names, environment variables, and runtime properties.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/native/mono/xamarin-app-stub/xamarin-app.hh | Remove data pointer, add buffer_offset and top-level symbols for counts, descriptors[], and data_buffer[]. |
src/native/mono/xamarin-app-stub/application_dso_stub.cc | Stub globals now use compressed_assembly_count , compressed_assembly_descriptors[] , and data buffer symbols. |
src/native/mono/monodroid/embedded-assemblies.cc | Decompression now indexes into a shared buffer via buffer_offset with added bounds checks. |
src/native/mono/monodroid/assembly-store.cc | Parallel decompression refactor in AssemblyStore : use buffer offsets and bounds checks. |
src/native/clr/xamarin-app-stub/application_dso_stub.cc | Update CLR stub globals to use index arrays and data blobs instead of pointer arrays. |
src/native/clr/include/xamarin-app.hh | Update all structs (assemblies, DSO cache, runtime properties, environment vars) to use index fields. |
src/native/clr/include/runtime-base/monodroid-dl.hh | Add get_dso_name helper to read names from a single blob via name_index . |
src/native/clr/host/host.cc | Use runtime_properties_data blob and indices in clr_get_runtime_property . |
src/native/clr/host/assembly-store.cc | Mirror native AssemblyStore refactor for CLR host code, using buffer offsets. |
src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrStringBlob.cs | Add XML summary for Add and describe its behavior. |
src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrGenerator.cs | Special-case zero-length arrays when emitting bytes, adjusting indentation/comma logic. |
src/Xamarin.Android.Build.Tasks/Utilities/CompressedAssembliesNativeAssemblyGenerator.cs | Remove old pointer-based struct providers; emit count, descriptors array, and data buffer globals. |
src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGeneratorCLR.cs | Update CLR generator to emit new blobs and index structs for env vars, DSO names, and runtime props. |
Comments suppressed due to low confidence (1)
src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrStringBlob.cs:29
- [nitpick] The XML doc comment for Add is missing
<param>
and<returns>
tags. Consider adding<param name="s">The string to add.</param>
and<returns>Tuple of offset and length in the blob.</returns>
for completeness.
/// <summary>
Another in series of PRs which reduces the number of relocations in
libxamarin-app.so
.This PR changes the way compressed assemblies (CoreCLR and MonoVM),
environment variables (CoreCLR) and runtime properties (CoreCLR)
are stored.
Compressed assemblies no longer use one target buffer per assembly,
but instead allocate a single big buffer for all the decompressed
assemblies, addressing the data using indexes into the buffer instead
of pointers.
Environment variables and runtime properties now use string blobs
instead of string pointers.
For the
dotnet new maui -sc
sample, this PR reduces the number ofrelocations in
libxamarin-app.so
from 394 (in themain
branch)to 136 entries.
Size of
libxamarin-app.so
is slightly reduced:Modest improvements in startup time, the sample app starts faster by
0.71% on Pixel 9 with Android 16.