From 08e0023b3dc5aeb5c7173cb456c24398d93dd815 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Wed, 10 Nov 2021 19:19:35 +0100 Subject: [PATCH] [release/6.0][wasm] Change dotnet.wasm link optimization (#60632) * [wasm] Change dotnet.wasm link optimization Context: https://github.com/dotnet/runtime/issues/60349 When we switched to Emscripten 2.0.21, we stopped using deprecated `--llvm-opts 2` option. This caused unwanted performance degradation. Switching to `-O2` get us similar performance as with `--llvm-opts`. Blazor wasm test app `Time to first UI` benchmark times: branch/commit link option time dotnet.wasm size --------------------+------------+--------+----------------- release/6.0 92ff02 -Oz 491ms 2,430,639 release/6.0 92ff02 -O2 457ms 2,474,518 release/6.0 92ff02 -O3 444ms 2,555,824 * Fix native build too Co-authored-by: Larry Ewing --- src/mono/wasm/Makefile | 2 +- src/mono/wasm/build/WasmApp.Native.targets | 1 + src/mono/wasm/wasm.proj | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/Makefile b/src/mono/wasm/Makefile index 52e5de9e302..63e03b22546 100644 --- a/src/mono/wasm/Makefile +++ b/src/mono/wasm/Makefile @@ -72,7 +72,7 @@ MONO_LIBS = \ $(ICU_LIBDIR)/libicui18n.a EMCC_DEBUG_FLAGS =-g -Os -s -DDEBUG=1 -EMCC_RELEASE_FLAGS=-Oz +EMCC_RELEASE_FLAGS=-O2 ifeq ($(NOSTRIP),) STRIP_CMD=&& $(EMSDK_PATH)/upstream/bin/wasm-opt --strip-dwarf $(NATIVE_BIN_DIR)/dotnet.wasm -o $(NATIVE_BIN_DIR)/dotnet.wasm diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index e564d43520b..22538f7ee77 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -161,6 +161,7 @@ <_EmccOptimizationFlagDefault Condition="'$(_EmccOptimizationFlagDefault)' == ''">-Oz $(_EmccOptimizationFlagDefault) + -O2 $(EmccCompileOptimizationFlag) <_EmccCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 3eacc3e1307..1051ff672f9 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -180,7 +180,7 @@ -g -Os -s -DENABLE_NETCORE=1 -DDEBUG=1 - -Oz -DENABLE_NETCORE=1 + -O2 -DENABLE_NETCORE=1 "$(EMSDK_PATH)/upstream/bin/wasm-opt" --strip-dwarf "$(NativeBinDir)dotnet.wasm" -o "$(NativeBinDir)dotnet.wasm" $(ArtifactsObjDir)wasm $(WasmObjDir)\emcc-version.txt -- 2.34.1