
# Objective - Many strings in bevy_ecs are created but only used for debug: system name, component name, ... - Those strings make a significant part of the final binary and are no use in a released game ## Solution - Use [`strings`](https://linux.die.net/man/1/strings) to find ... strings in a binary - Try to find where they come from - Many are made from `type_name::<T>()` and only used in error / debug messages - Add a new structure `DebugName` that holds no value if `debug` feature is disabled - Replace `core::any::type_name::<T>()` by `DebugName::type_name::<T>()` ## Testing Measurements were taken without the new feature being enabled by default, to help with commands ### File Size I tried building the `breakout` example with `cargo run --release --example breakout` |`debug` enabled|`debug` disabled| |-|-| |81621776 B|77735728B| |77.84MB|74.13MB| ### Compilation time `hyperfine --min-runs 15 --prepare "cargo clean && sleep 5" 'RUSTC_WRAPPER="" cargo build --release --example breakout' 'RUSTC_WRAPPER="" cargo build --release --example breakout --features debug'` ``` breakout' 'RUSTC_WRAPPER="" cargo build --release --example breakout --features debug' Benchmark 1: RUSTC_WRAPPER="" cargo build --release --example breakout Time (mean ± σ): 84.856 s ± 3.565 s [User: 1093.817 s, System: 32.547 s] Range (min … max): 78.038 s … 89.214 s 15 runs Benchmark 2: RUSTC_WRAPPER="" cargo build --release --example breakout --features debug Time (mean ± σ): 92.303 s ± 2.466 s [User: 1193.443 s, System: 33.803 s] Range (min … max): 90.619 s … 99.684 s 15 runs Summary RUSTC_WRAPPER="" cargo build --release --example breakout ran 1.09 ± 0.05 times faster than RUSTC_WRAPPER="" cargo build --release --example breakout --features debug ```
41 lines
1023 B
TOML
41 lines
1023 B
TOML
[package]
|
|
name = "bevy_utils"
|
|
version = "0.16.0-dev"
|
|
edition = "2024"
|
|
description = "A collection of utils for Bevy Engine"
|
|
homepage = "https://bevy.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
keywords = ["bevy"]
|
|
|
|
[features]
|
|
default = ["parallel"]
|
|
|
|
wgpu_wrapper = ["dep:send_wrapper"]
|
|
|
|
# Provides access to the `Parallel` type.
|
|
parallel = ["bevy_platform/std", "dep:thread_local"]
|
|
|
|
std = ["disqualified/alloc"]
|
|
|
|
debug = []
|
|
|
|
[dependencies]
|
|
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-features = false }
|
|
|
|
disqualified = { version = "1.0", default-features = false }
|
|
thread_local = { version = "1.0", optional = true }
|
|
|
|
[target.'cfg(all(target_arch = "wasm32", target_feature = "atomics"))'.dependencies]
|
|
send_wrapper = { version = "0.6.0", optional = true }
|
|
|
|
[dev-dependencies]
|
|
static_assertions = "1.1.0"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.docs.rs]
|
|
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
|
|
all-features = true
|