From d8d3b438973784b3935e3e18a7ea8690859b3e24 Mon Sep 17 00:00:00 2001 From: Kento Sugama <107421898+kentosugama@users.noreply.github.com> Date: Wed, 27 Sep 2023 13:10:35 -0400 Subject: [PATCH] Document aggressive inlining options (#46) Co-authored-by: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3cc1655..2aa9806 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,13 @@ Usage: `ic-wasm info` Remove unused functions and debug info. +Note: The `icp` metadata sections are preserved through the shrink. + Usage: `ic-wasm -o shrink` -Optionally invoke wasm optimizations from [`wasm-opt`](https://github.com/WebAssembly/binaryen). +### Optimize + +Invoke wasm optimizations from [`wasm-opt`](https://github.com/WebAssembly/binaryen). The optimizer exposes different optimization levels to choose from. @@ -69,8 +73,16 @@ The recommended setting (O3) reduces cycle usage for Motoko programs by ~10% and Note: The `icp` metadata sections are preserved through the optimizations. +Usage: `ic-wasm -o optimize ` + +There are two further flags exposed from `wasm-opt`: +- `--inline-functions-with-loops` +- `--always-inline-max-function-size ` + +These were exposed to aggressively inline functions, which are common in Motoko programs. With the new cost model, there is a large performance gain from inlining functions with loops, but also a large blowup in binary size. Due to the binary size increase, we may not be able to apply this inlining for actor classes inside a Wasm module. -Usage: `ic-wasm -o shrink --optimize ` +E.g. +`ic-wasm -o optimize O3 --inline-functions-with-loops --always-inline-max-function-size 100` ### Resource