From 6c197be69bbf271f69e88f7dbfd6e53b9c006a35 Mon Sep 17 00:00:00 2001 From: Ben Frankel Date: Mon, 15 Jul 2024 11:01:31 -0700 Subject: [PATCH] Update optimization suggestions based on benchmark (#1553) --- .../quick-start/getting-started/setup.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/content/learn/quick-start/getting-started/setup.md b/content/learn/quick-start/getting-started/setup.md index e6239d1e7c..1e6515b856 100644 --- a/content/learn/quick-start/getting-started/setup.md +++ b/content/learn/quick-start/getting-started/setup.md @@ -130,11 +130,11 @@ It's not uncommon for debug builds using the default configuration to take multi Fortunately, there is a simple fix, and we don't have to give up our fast iterative compiles! Add the following to your `Cargo.toml`: ```toml -# Enable a small amount of optimization in debug mode. +# Enable a small amount of optimization in the dev profile. [profile.dev] opt-level = 1 -# Enable a large amount of optimization in debug mode for dependencies. +# Enable a large amount of optimization in the dev profile for dependencies. [profile.dev.package."*"] opt-level = 3 ``` @@ -144,23 +144,23 @@ You might think to simply develop in release mode instead, but we recommend agai In fact, you may want to trade even more compile time for performance in release mode by adding the following to your `Cargo.toml`: ```toml -# Enable more optimization in release mode at the cost of compile time. +# Enable more optimization in the release profile at the cost of compile time. [profile.release] # Compile the entire crate as one unit. -# Significantly slows compile times, marginal improvements. +# Slows compile times, marginal improvements. codegen-units = 1 # Do a second optimization pass over the entire program, including dependencies. -# Slightly slows compile times, marginal improvements. +# Slows compile times, marginal improvements. lto = "thin" -# Optimize for size in wasm-release mode to reduce load times and bandwidth usage on web. +# Optimize for size in the wasm-release profile to reduce load times and bandwidth usage on web. [profile.wasm-release] -# Use release profile as default values. +# Default to release profile values. inherits = "release" -# Optimize with size in mind (also try "s", sometimes it is better). -# This doesn't increase compilation times compared to -O3, great improvements. -opt-level = "z" -# Strip all debugging information from the binary to reduce file size. +# Optimize with size in mind (also try "z", sometimes it is better). +# Slightly slows compile times, great improvements to file size and runtime performance. +opt-level = "s" +# Strip all debugging information from the binary to slightly reduce file size. strip = "debuginfo" ``` @@ -172,7 +172,7 @@ When releasing for web, you can pass `--profile wasm-release` to `cargo` instead that provides a `wasm-opt` CLI tool for making `.wasm` files smaller and faster: ```sh -wasm-opt -Oz --output output.wasm input.wasm +wasm-opt -Os --output output.wasm input.wasm ``` Note that `wasm-opt` runs very slowly, but it can make a _big_ difference, especially