Carter
07/23/2024, 11:54 PMcompileProductionExecutableKotlinWasmJsOptimize
, at over 7 minutes for a fairly small application (that otherwise only takes 4 minutes to build when the wasmJs target is disabled). Are there any configurable options that could improve the performance of this task? I imagine the binaryen optimization is what is taking the majority of this time.Rok Oblak
07/24/2024, 6:28 AMSvyatoslav Kuzmich [JB]
07/24/2024, 8:44 AMwasm-opt
process that won’t be affected by JVM flags. You can configure binaryen flags in Gradle. I’ll recreate the default setup, separating the required and optional flags:
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenExec> {
binaryenArgs = mutableListOf(
// Required flags:
"--enable-gc",
"--enable-reference-types",
"--enable-exception-handling",
"--enable-bulk-memory",
"--enable-nontrapping-float-to-int",
// Optional flags (can be removed):
"--inline-functions-with-loops",
"--traps-never-happen",
"--fast-math",
"-O3",
"-O3",
"--gufa",
"-O3",
"-O3",
"-Oz",
)
}
You can then remove some of the -O3
flags to speed it up. See https://github.com/WebAssembly/binaryen/wiki/GC-Optimization-Guidebook for more details.Carter
07/24/2024, 1:11 PMexport BINARYEN_PASS_DEBUG=1
provides debug info on each optimization.
On my Mac Studio, the slowest (by an order of magnitude) steps are:
[PassRunner] running pass: dae-optimizing... 9.05247 seconds.
[PassRunner] running pass: inlining-optimizing... 10.6519 seconds.
On a GitHub Actions larger runner (8 core ARM 64 Ubuntu), the slowest two steps are:
[PassRunner] running pass: dae-optimizing... 64.1798 seconds.
[PassRunner] running pass: inlining-optimizing... 88.8491 seconds.
Can you think of a reason why these would be 10x slower on CI?Carter
07/24/2024, 1:11 PM