[CoreCLR] Attempt to replace xxhash with crc32#12013
Draft
simonrozsival wants to merge 15 commits into
Draft
Conversation
Replace CoreCLR LLVM typemap xxHash lookups with CRC32 hashes from System.IO.Compression.Native. Keep collision-safe lookup by comparing the original managed or Java type name after matching the hash. This is a first step toward removing the CoreCLR xxHash dependency to reduce size while preserving runtime lookup performance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Emit CoreCLR assembly stores with 32-bit CRC32 name hashes and update the CoreCLR native assembly-store lookup to use the shared CRC32 helper. Keep MonoVM assembly stores on the existing xxHash layout, bump the CoreCLR store format to v4, and update the mk2 store reader to infer index entry width from the header index size. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace CoreCLR runtime property, DSO APK, and DSO/AOT cache xxHash lookups with CRC32 hashes from the shared native CRC32 helper. Update generated CoreCLR app config, desktop app stub data, and strict generated-layout test parsing for the smaller 32-bit hash fields. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Switch the CoreCLR dynamic p/invoke override and generated find_pinvoke tables to 32-bit CRC32 hashes. Keep the precompiled p/invoke table on the existing xxHash layout while removing xxHash from the shared p/invoke override header and fallback cache path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Switch the CoreCLR precompiled p/invoke override table and generator to 32-bit CRC32 hashes. This removes the remaining CoreCLR p/invoke override dependency on xxHash while keeping the table collision check in the generator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the common Search helper generic-only and move the xxHash-specific overloads to a MonoVM-only search-xxhash.hh wrapper. This prevents CoreCLR native code from including shared/xxhash.hh through the common search helper while preserving MonoVM's existing hash_t search callsites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop adding external/xxHash and constexpr-xxh3 include paths to CoreCLR native targets now that CoreCLR no longer includes shared/xxhash.hh. Keep the xxHash include support available for MonoVM and NativeAOT paths that still use it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce a CoreCLR-local hash_t alias to uint32_t in the CRC32 helper and use it for CoreCLR hash fields, lookup signatures, and generated p/invoke tables. This keeps the code readable without reintroducing the shared xxHash wrapper or changing MonoVM's hash_t layout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a compile-time crc32_hash overload for string literals and use it in CoreCLR generated/default tables instead of hardcoded hex hash values. This keeps the generated p/invoke table and app stub self-documenting while preserving the runtime CRC32 helper for dynamic strings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allow generated-environment tests to parse decimal uint32 values above Int32.MaxValue and update CoreCLR APK size baselines after the CRC32 native size changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the CoreCLR debug typemap string fallback now that CRC32 lookups verify matching strings, and remove the unused CoreCLR AOT DSO cache path while failing fast if a CoreCLR config tries to use it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse the runtime property arrays passed to coreclr_initialize for the host runtime contract callback instead of emitting a duplicate CRC32-indexed lookup table. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Leave the host runtime contract in place for p/invoke and assembly probing, but set get_runtime_property to null because Android passes runtime configuration through coreclr_initialize and the callback only produced negative host-property probes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove unused CoreCLR application config structure-info fields that were only kept for potential future host configuration data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Goal
Remove the CoreCLR native dependency on xxHash/constexpr-xxh3 in .NET for Android lookup paths while preserving runtime behavior and startup performance. The primary improvement is dependency removal; app size and startup time are expected to be unchanged within measurement noise.
Summary
Benchmark
CoreCLR MAUI Release/R2R sample, Android arm64, Samsung SM-A165F, interleaved runs, no reboot. The comparison below uses #12010 as the xxHash baseline because it contains the p/invoke resolver cleanup needed to run with the current runtime packs; this isolates the CRC32/dependency-removal changes in this PR.
Size
Startup, 30x mixed cold + hot, IQR outliers removed
Result: app size and startup times are unchanged within measurement noise. The meaningful win is removing CoreCLR's dependency on the xxHash/constexpr-xxh3 native dependency chain.
Validation