Skip to content

Commit

Permalink
[wasm] Raise default initial heap size minimum (#99927)
Browse files Browse the repository at this point in the history
The current minimum heap size (16mb) is too small for sgen to successfully start up without growing the heap, so this raises it to 32mb
  • Loading branch information
kg committed Mar 19, 2024
1 parent e450d8e commit 34dc259
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/mono/browser/browser.proj
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@
<_EmccExportedLibraryFunction>"[@(EmccExportedLibraryFunction -> '%27%(Identity)%27', ',')]"</_EmccExportedLibraryFunction>
<_EmccExportedRuntimeMethods>"[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]"</_EmccExportedRuntimeMethods>
<_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions>
<EmccInitialHeapSize>16777216</EmccInitialHeapSize>
<!-- reserve at least enough space to complete initializing sgen without growing the heap -->
<EmccInitialHeapSize>33554432</EmccInitialHeapSize>
<EmccStackSize>5MB</EmccStackSize>
</PropertyGroup>
<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/mono/wasm/build/WasmApp.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- $(EmccExtraCFlags) - Extra emcc flags for compiling native files
- $(EmccEnableAssertions) - Corresponds to `ASSERTIONS` arg for emcc. Default false.
- $(EmccEnvironment) - Corresponds to `ENVIRONMENT` arg for emcc. Default is `web,webview,worker,node,shell`.
- $(WasmInitialHeapSize) - Initial heap size specified with `emcc`. Default value: 16777216 or size of the DLLs, whichever is larger.
- $(WasmInitialHeapSize) - Initial heap size specified with `emcc`. Default value: 33554432 or size of the DLLs, whichever is larger.
Corresponds to `-s INITIAL_MEMORY=...` emcc arg.
(previously named EmccTotalMemory, which is still kept as an alias)
- $(EmccMaximumHeapSize) - Maximum heap size specified with `emcc`. Default value: 2147483648 or size of the DLLs, whichever is larger.
Expand Down Expand Up @@ -501,14 +501,14 @@
Text="$(_ToolchainMissingErrorMessage) SDK is required for AOT'ing assemblies." />

<ItemGroup>
<_ChangedBoolPropertiesThatTriggerRelinking Include="%(_BoolPropertiesThatTriggerRelinking.Identity)" Condition="'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '' and
<_ChangedBoolPropertiesThatTriggerRelinking Include="%(_BoolPropertiesThatTriggerRelinking.Identity)" Condition="'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '' and
'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '%(_BoolPropertiesThatTriggerRelinking.DefaultValueInRuntimePack)'" />
</ItemGroup>
<PropertyGroup>
<_WasmBuildNativeRequired Condition="@(_ChangedBoolPropertiesThatTriggerRelinking->Count()) > 0">true</_WasmBuildNativeRequired>
</PropertyGroup>

<Error Condition="'$(WasmBuildNative)' == 'false' and '$(_WasmBuildNativeRequired)' == 'true'"
<Error Condition="'$(WasmBuildNative)' == 'false' and '$(_WasmBuildNativeRequired)' == 'true'"
Text="WasmBuildNative is required because %(_ChangedBoolPropertiesThatTriggerRelinking.Identity)=$(%(_ChangedBoolPropertiesThatTriggerRelinking.Identity)), but WasmBuildNative is already set to 'false'." />

<PropertyGroup>
Expand Down Expand Up @@ -584,8 +584,8 @@
<Output TaskParameter="InitialHeapSize" PropertyName="_WasmCalculatedInitialHeapSize" />
</WasmCalculateInitialHeapSize>
<PropertyGroup>
<WasmInitialHeapSize Condition="'$(WasmInitialHeapSize)' == '' and '$(_WasmCalculatedInitialHeapSize)' != '' and $(_WasmCalculatedInitialHeapSize) > 16777216">$(_WasmCalculatedInitialHeapSize)</WasmInitialHeapSize>
<WasmInitialHeapSize Condition="'$(WasmInitialHeapSize)' == ''">16777216</WasmInitialHeapSize>
<WasmInitialHeapSize Condition="'$(WasmInitialHeapSize)' == '' and '$(_WasmCalculatedInitialHeapSize)' != '' and $(_WasmCalculatedInitialHeapSize) > 33554432">$(_WasmCalculatedInitialHeapSize)</WasmInitialHeapSize>
<WasmInitialHeapSize Condition="'$(WasmInitialHeapSize)' == ''">33554432</WasmInitialHeapSize>
</PropertyGroup>
</Target>

Expand Down

0 comments on commit 34dc259

Please sign in to comment.