[browser][coreCLR] reduce initial memory footprint#127905
Conversation
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
There was a problem hiding this comment.
Pull request overview
This PR reduces the default WebAssembly memory and stack settings used by the CoreCLR browser host, aiming to lower the initial memory footprint during startup (per #127880).
Changes:
- Decrease Emscripten
INITIAL_MEMORYfrom 128 MB to 32 MB forbrowserhost. - Decrease Emscripten
STACK_SIZEfrom 5 MB to 2 MB forbrowserhost. - Keep the MSBuild CoreCLR WASM relink targets in sync with the
browserhostCMake configuration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/native/corehost/browserhost/CMakeLists.txt | Lowers default INITIAL_MEMORY and STACK_SIZE link options for the browser host to reduce startup footprint. |
| src/mono/browser/build/BrowserWasmApp.CoreCLR.targets | Mirrors the updated memory/stack defaults in the CoreCLR WASM relink pipeline so app relinks match the host configuration. |
radekdoulik
left a comment
There was a problem hiding this comment.
LGTM, let see if CI tests will pass. Thank you!
|
There are more places where this is hardcoded: Is this inconsistency intentional? |
Yes, that is Mono |
|
What's the reasoning behind lower limits for CoreCLR? Is there a problem with applying the same lower limits to Mono as well? |
It's "see how low we can set it before things break".
The 32MB is matching Mono default value. I remember you said <20MB should be possible. Do you want to try that ? Blazor template app uses 84MB large linear memory to start on this branch.
Mono AOT in particular has big Right now Mono is "don't touch it" territory. @jkotas do you have specific concern or just curiosity ? |
Stack size is user observable. Smaller stack size should be better for perf, but it can break user apps. I think it is ok to change it for CoreCLR. It is a breaking change though. We may want to mention it in the Mono -> CoreCLR breaking change notice that we are going to file eventually.
This comment was about the GC heap size specifically. It was not about the total memory consumption.
What is the user observable impact of this change? For example, do you see a smaller working set reported by the OS for a typical wasm app or test? Can this regress startup time for a typical wasm app? (I assume that the growing memory has some time overhead, hopefully it is neglible.) You will always see me asking questions on perf-related PRs that do not have any numbers in the descriptions ;-) |
|
/ba-g known infra issue |
@jkotas we are getting there. Macrobenchmark can now run measurement on PR/branch. It will take some time until the code flows thru VMR into preview builds.
|



Fixes #127880