Add bevy_transform benchmarks#23906
Conversation
bevy_transform benchmarks and align feature gates
|
I really like both of these changes, but can you please split them into two separate PRs to make them easier to review? :) |
bevy_transform benchmarks and align feature gatesbevy_transform benchmarks
Thanks for the suggestion. I've rebased this PR onto the latest upstream, and it now only includes the benchmark. The other part will be moved to a separate PR. |
alice-i-cecile
left a comment
There was a problem hiding this comment.
Benchmarks look fine to me, and I think that including dedicated micro-benchmarks for this is very reasonable.
The Cargo.toml change needs to reverted for this PR though :)
This reverts commit 052a06a.
There was a problem hiding this comment.
I haven't written any benchmarks before using criterion (at least that I can recall) but this looks very well constructed to me, except for the minor nit about the schedule ordering.
It'd be nice if we could set up something similar for UI transforms and layout.
Co-Authored-By: ickshonpe <27962798+ickshonpe@users.noreply.github.com>
# Objective `bevy_transform`'s multi-threading behavior was previously gated on `feature = "std"`, which incorrectly conflated standard library availability with multi-threading capability. This means: - Users who enabled `no_std` but had multi-threading available lost parallelism unintentionally. - Users who had `std` but wanted single-threaded execution (e.g. WASM) still attempted to use the parallel path. - `bevy_internal`'s `multi_threaded` feature did not propagate down to `bevy_transform`, so the parallel implementation was not activated when expected. - The `bevy_log` dependency was pulled in unconditionally via the `std` feature, when the only use was optional trace-level warnings. ## Solution - Added an explicit `multi_threaded` feature to `bevy_transform`, backed by `bevy_tasks/multi_threaded`, matching the pattern used by `bevy_ecs` and other crates. - Replaced all `#[cfg(feature = "std")]` / `#[cfg(not(feature = "std"))]` guards on parallel/serial code paths with `#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]` / `#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))]` — the same guard pattern already used in `bevy_ecs`. - Added `bevy_transform/multi_threaded` to `bevy_internal`'s and `bevy_render`'s `multi_threaded` feature lists so parallel transforms are activated end-to-end when building Bevy with `multi_threaded`. - Removed the `bevy_log` dependency from `bevy_transform`. Its sole usage was a `warn_once!` inside `propagate_transforms_for`. This is replaced with a direct `tracing::warn!` wrapped in `bevy_utils::once!`, gated on a new opt-in `trace` feature (`dep:tracing`). This keeps the default build lighter. - Inlined the `trace` feature spans in `mark_dirty_trees` that previously depended on `bevy_log`'s re-exported `tracing`, now using `tracing` directly under `#[cfg(feature = "trace")]`. ## Testing - All existing unit tests in `bevy_transform::systems::test` pass unchanged — no behavioral changes, only cfg guard corrections. - No performance regressions observed by [Benchmark](bevyengine#23906). --- --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
Objective
bevy_transform's propagation systems to catch performance regressions.Solution
Benchmarks (
benches/benches/bevy_transform/propagate.rs):Added small benchmarks targeting each stage of the propagation pipeline individually.
mark_dirty_trees— localized vs. distributed leaf update patternspropagate_parent_transforms— full recompute with roots changed vs. leaves changed (static optimization disabled to isolate traversal cost)transform_pipeline— end-to-end pipeline with static optimization on/off, plusChildOfreparent churnThe hierarchy setup uses 48 roots × 6 depth layers with mixed fanout (4-4-3-3-2-2) and extra archetype padding (
MarkerA/B/C) to reflect realistic gameplay scenes.Testing