From 614bd1d88c0f543d80353d96889052a86518495a Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 16 Jul 2026 13:23:01 +0800 Subject: [PATCH] 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). --- Cargo.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 7556a93..2e6c3bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"