perf(build): add fat LTO + single codegen-unit to desktop release profile

The renderer is GPU-bound, but Bevy's CPU path (resource management,
system scheduling, egui, wgpu command submission) still benefits from
cross-crate inlining. Cargo's default release profile skips LTO and
splits codegen across 16 units, leaving inter-crate trampolines through
Bevy/wgpu in the hot path.

- lto = "fat": whole-program cross-crate inlining.
- codegen-units = 1: best optimization (slower compiles, accepted).
- panic = "abort": smaller binary, no unwind tables.
- strip = "symbols": drop debug symbols from the shipped binary.

wasm-release inherits release then overrides opt-level to "z", so web
builds keep their size focus. Release build verified; cargo test green
(14 passed).
This commit is contained in:
xfy 2026-07-16 13:23:01 +08:00
parent 2d764f5f19
commit 614bd1d88c

View File

@ -17,6 +17,21 @@ web-sys = { version = "0.3", features = ["Gpu", "Navigator", "Window", "Document
wasm-bindgen = "0.2"
js-sys = "0.3"
# Desktop release tuning. This renderer is GPU-bound, but Bevy's CPU path
# (resource management, system scheduling, egui, wgpu command submission)
# still benefits measurably from cross-crate LTO and a single codegen unit:
# - lto = "fat": cross-crate inlining, removes trampolines through Bevy/wgpu.
# - codegen-units = 1: best optimization, at the cost of slower compiles.
# - panic = "abort": smaller binary, no unwind tables in the hot path.
# - strip: drop debug symbols from the shipped binary.
# `wasm-release` inherits release, so web picks these up too (then overrides
# opt-level to "z" for binary size).
[profile.release]
lto = "fat"
codegen-units = 1
panic = "abort"
strip = "symbols"
# Smaller wasm binary in release web builds (per Bevy examples README).
[profile.wasm-release]
inherits = "release"