Disable server GC and background GC for CoreCLR WebAssembly builds#127178
Disable server GC and background GC for CoreCLR WebAssembly builds#127178
Conversation
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/ef405ab1-bc2a-472f-b797-52d49c5d8409 Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/gc |
|
@copilot let's disable the background GC for WASM too. |
|
cc: @radekdoulik FYI |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/05b0c780-4d5e-4177-b5ec-c07a31e050a7 Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
…eLoadedBeforeCodeIsRun, and reportTailCallDecision Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/05b0c780-4d5e-4177-b5ec-c07a31e050a7 Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/7f661e48-3027-488a-8ca9-5fc83d287082 Co-authored-by: janvorli <10758568+janvorli@users.noreply.github.com>
Done in dc7b9f9. Added Additional savings from disabling background GC: 47,527 bytes raw / 15,680 bytes brotli, bringing the total vs baseline to 93,330 bytes raw (2.2%) / 25,599 bytes brotli (2.0%). |
|
@copilot please undo the changes in the jitinterface.cpp, these are unrelated to the GC changes. |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b8ad1421-bfb6-48e3-8387-923a7d1cc0dc Co-authored-by: janvorli <10758568+janvorli@users.noreply.github.com>
Done in c6d22cb. The |
| GC_HEAP_FIELD(OomData, oom_info) | ||
|
|
||
| /* For use in GCHeapDetails APIs */ | ||
| #ifdef BACKGROUND_GC |
There was a problem hiding this comment.
@davidwrighton is this ok for CDAC, assuming that disabling background GC is a WASM only thing?
There was a problem hiding this comment.
Pull request overview
This PR applies CoreCLR WebAssembly-specific build/feature gating to reduce binary size by removing GC modes that are not intended to be used/supported on WASM builds.
Changes:
- Suppress
FEATURE_SVR_GCfor WebAssembly targets in CoreCLR CMake definitions. - Disable
BACKGROUND_GCwhen compiling forTARGET_WASM. - Update GC cDAC descriptors to only describe background-GC-only fields/globals when
BACKGROUND_GCis defined.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/gc/gcpriv.h | Guards BACKGROUND_GC so it is not enabled for TARGET_WASM. |
| src/coreclr/gc/datadescriptor/datadescriptor.h | Wraps background-GC-only gc_heap field descriptors in #ifdef BACKGROUND_GC. |
| src/coreclr/gc/datadescriptor/datadescriptor.inc | Wraps background-GC-only cDAC globals in #ifdef BACKGROUND_GC. |
| src/coreclr/clrdefinitions.cmake | Avoids defining FEATURE_SVR_GC for WASM target builds. |
|
|
||
| #ifndef TARGET_WASM | ||
| #define BACKGROUND_GC //concurrent background GC (requires WRITE_WATCH) | ||
| #endif //!TARGET_WASM |
There was a problem hiding this comment.
The #endif trailing comment style here is inconsistent with the surrounding codebase (typically #endif // !TARGET_WASM with a space after //). Consider adjusting this for consistency/readability.
| #endif //!TARGET_WASM | |
| #endif // !TARGET_WASM |
Description
Applies two complementary size optimizations for CoreCLR WebAssembly builds, which use the interpreter instead of the traditional JIT:
Disable server GC —
FEATURE_SVR_GCis suppressed for WebAssembly inclrdefinitions.cmake. WebAssembly is single-threaded and has no use for server GC's multi-heap design.Disable background GC — Background GC (concurrent GC) requires
WRITE_WATCHsupport and background threads, neither of which is available on WebAssembly.BACKGROUND_GCis now suppressed with a#ifndef TARGET_WASMguard ingcpriv.h. Thedatadescriptor.handdatadescriptor.inccDAC descriptor files are updated to guard the fields and globals that only exist whenBACKGROUND_GCis defined.Size measurements (
corerun.wasm)