Skip to content

Noticeable schedules running overhead  #11932

Description

@chengts95

Bevy version 0.13

  • Original: 0.12.1 release from Cargo.
  • Current: 0.13.0 release from Cargo.

Relevant system information

Please include:

  • The Rust version you're using: 1.76
  • the operating system or browser used, including its version
    • Windows 11, Ubuntu 22.04

What's performing poorly?

The schedule is running slower than before, which slowed down my program by 20%. This can impact the performance of real-time simulation applications and may significantly lower the performance when you scale the systems with more schedule plans.

It can be reproduced by running empty schedules:

use std::time::Instant;

use bevy_ecs::schedule;
use bevy_app::prelude::*;

fn main() {
    let mut app = bevy_app::App::default();
    app.add_schedule(schedule::Schedule::new(First));
    app.add_schedule(schedule::Schedule::new(PreUpdate));
    app.add_schedule(schedule::Schedule::new(Update));
    app.add_schedule(schedule::Schedule::new(PostUpdate));
    app.add_schedule(schedule::Schedule::new(Last));
    let now = Instant::now();
    for _i in 0..20_000_000 {
        app.update();
    }
    println!("{}", now.elapsed().as_micros() as f64 / 1e6);
  
}

Performance table for this code:
With LTO = yes

Test Case Time Slow Down
bevy_ecs 0.12.1 13.694943 0%
bevy_ecs 0.13, default-features = false 14.759885 7.778%
bevy_ecs 0.13 15.566676 13.7%

With LTO turned-off

Test Case Time Slow Down
bevy_ecs 0.12.1 15.359637 0%
bevy_ecs 0.13, default-features = false 16.61063 8%
bevy_ecs 0.13 17.642636 14.9%

The slowing down is obvious, and I don't use the profiler because such overhead is not caused by user systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorC-PerformanceA change motivated by improving speed, memory usage or compile timesP-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions