Repository navigation
Add some ifdefs to allow trimming more GC code - #137498
Merged
Merged
Conversation
Allow the compiler to eliminate unsupported heap-decommit paths while preserving the mutable setting on other platforms. Reduces stripped NativeAOT WASI HelloWorldSize from 679,537 to 677,542 bytes, saving 1,995 bytes (0.29%). Validated the WASI Release NativeAOT runtime build and HelloWorldSize build/run (exit 100). Co-authored-by: Copilot <[email protected]> Copilot-Session: e1b16afd-ac3c-4144-ae84-b4a37986ab3c
Define FEATURE_HOST_TRACE for CoreCLR and compile GC host-error logging calls away when it is unavailable, avoiding discarded formatting in NativeAOT. Reduces stripped NativeAOT WASI HelloWorldSize from 677,542 to 665,974 bytes, saving 11,568 bytes (1.71%). Validated the WASI Release NativeAOT runtime build, CoreCLR GC logging compilation, and HelloWorldSize build/run (exit 100). Co-authored-by: Copilot <[email protected]> Copilot-Session: e1b16afd-ac3c-4144-ae84-b4a37986ab3c
Keep manual-reset and auto-reset event state without pthread synchronization when FEATURE_MULTITHREADING is disabled. Return timeout for unsignaled polling and assert/fail for unsupported blocking waits, matching the existing single-threaded event policy. Reduces stripped NativeAOT WASI HelloWorldSize from 665,974 to 662,805 bytes, saving 3,169 bytes (0.48%). Validated the WASI Release NativeAOT runtime build and HelloWorldSize build/run (exit 100), syntax-checked the threaded branch, and confirmed the single-threaded GCEvent object has no pthread references. Co-authored-by: Copilot <[email protected]> Copilot-Session: e1b16afd-ac3c-4144-ae84-b4a37986ab3c
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @anicka-net, @dotnet/gc |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Finite GC notification waits incorrectly assert or return Failed instead of timing out, so the unsupported-blocking assertion must be limited to infinite waits.
1 open issue
What changed in this PR
This PR adds compile-time guards to make GC code easier to trim for WebAssembly applications. The description reports a 2.5% size reduction for a WASI Hello World.
Changes:
- Adds a lightweight GC event implementation for single-threaded builds.
- Makes the WebAssembly “never decommit” setting a compile-time constant.
- Guards GC initialization logging behind
FEATURE_HOST_TRACE, enabled for CoreCLR.
Review was source-only; builds and tests were not run.
| File | Description |
|---|---|
src/coreclr/gc/unix/events.cpp |
Adds single-threaded events without pthread synchronization. |
src/coreclr/gc/init.cpp |
Skips runtime assignment of the WebAssembly decommit setting. |
src/coreclr/gc/gcpriv.h |
Declares the decommit setting as constant on WebAssembly. |
src/coreclr/gc/gccommon.cpp |
Conditionally compiles initialization-error logging. |
src/coreclr/gc/gc.h |
Removes logging calls when host tracing is disabled. |
src/coreclr/gc/gc.cpp |
Omits mutable decommit-setting storage on WebAssembly. |
src/coreclr/clrdefinitions.cmake |
Enables host tracing for CoreCLR builds. |
Review effort: Balanced
MichalStrehovsky
enabled auto-merge (squash)
November 16, 2026 09:28
Member
Author
|
/ba-g failure is #137545 |
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
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.

2.5% size savings for a WASI Hello World. The individual commits have concrete numbers.