Skip to content

Commit

Permalink
Update optimization suggestions based on benchmark (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel authored Jul 15, 2024
1 parent 0fbc3a6 commit 6c197be
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions content/learn/quick-start/getting-started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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"
```

Expand All @@ -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
Expand Down

0 comments on commit 6c197be

Please sign in to comment.