Skip to content

Commit af8d12c

Browse files
ElliottjPiercealice-i-cecilesirius94
authored
deprecate SimpleExecutor (#18753)
# Objective Contributes to #18741 and #18453. ## Solution Deprecate `SimpleExecutor`. If users run into migration issues, we can backtrack. Otherwise, we follow this up with #18741 We can't easily deprecate the module too because of [this](rust-lang/rust#47238). ## Testing CI --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Cyrill Schenkel <cyrill.schenkel@gmail.com>
1 parent cdcb773 commit af8d12c

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

benches/benches/bevy_ecs/scheduling/schedule.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pub fn empty_schedule_run(criterion: &mut Criterion) {
137137
});
138138

139139
let mut schedule = Schedule::default();
140+
#[expect(deprecated, reason = "We still need to test/bench this.")]
140141
schedule.set_executor_kind(bevy_ecs::schedule::ExecutorKind::Simple);
141142
group.bench_function("Simple", |bencher| {
142143
bencher.iter(|| schedule.run(app.world_mut()));

crates/bevy_ecs/src/schedule/executor/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod single_threaded;
66
use alloc::{borrow::Cow, vec, vec::Vec};
77
use core::any::TypeId;
88

9+
#[expect(deprecated, reason = "We still need to support this.")]
910
pub use self::{simple::SimpleExecutor, single_threaded::SingleThreadedExecutor};
1011

1112
#[cfg(feature = "std")]
@@ -53,6 +54,10 @@ pub enum ExecutorKind {
5354
SingleThreaded,
5455
/// Like [`SingleThreaded`](ExecutorKind::SingleThreaded) but calls [`apply_deferred`](crate::system::System::apply_deferred)
5556
/// immediately after running each system.
57+
#[deprecated(
58+
since = "0.17.0",
59+
note = "Use SingleThreaded instead. See https://github.com/bevyengine/bevy/issues/18453 for motivation."
60+
)]
5661
Simple,
5762
/// Runs the schedule using a thread pool. Non-conflicting systems can run in parallel.
5863
#[cfg(feature = "std")]
@@ -346,6 +351,7 @@ mod tests {
346351
struct TestComponent;
347352

348353
const EXECUTORS: [ExecutorKind; 3] = [
354+
#[expect(deprecated, reason = "We still need to test this.")]
349355
ExecutorKind::Simple,
350356
ExecutorKind::SingleThreaded,
351357
ExecutorKind::MultiThreaded,
@@ -406,6 +412,7 @@ mod tests {
406412
let mut world = World::new();
407413
let mut schedule = Schedule::default();
408414

415+
#[expect(deprecated, reason = "We still need to test this.")]
409416
schedule.set_executor_kind(ExecutorKind::Simple);
410417
schedule.add_systems(look_for_missing_resource);
411418
schedule.run(&mut world);

crates/bevy_ecs/src/schedule/executor/simple.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![expect(deprecated, reason = "Everything here is deprecated")]
2+
13
use core::panic::AssertUnwindSafe;
24
use fixedbitset::FixedBitSet;
35

@@ -20,6 +22,10 @@ use super::__rust_begin_short_backtrace;
2022
/// A variant of [`SingleThreadedExecutor`](crate::schedule::SingleThreadedExecutor) that calls
2123
/// [`apply_deferred`](crate::system::System::apply_deferred) immediately after running each system.
2224
#[derive(Default)]
25+
#[deprecated(
26+
since = "0.17.0",
27+
note = "Use SingleThreadedExecutor instead. See https://github.com/bevyengine/bevy/issues/18453 for motivation."
28+
)]
2329
pub struct SimpleExecutor {
2430
/// Systems sets whose conditions have been evaluated.
2531
evaluated_sets: FixedBitSet,
@@ -165,7 +171,10 @@ impl SimpleExecutor {
165171
}
166172
}
167173
}
168-
174+
#[deprecated(
175+
since = "0.17.0",
176+
note = "Use SingleThreadedExecutor instead. See https://github.com/bevyengine/bevy/issues/18453 for motivation."
177+
)]
169178
fn evaluate_and_fold_conditions(conditions: &mut [BoxedCondition], world: &mut World) -> bool {
170179
let error_handler = default_error_handler();
171180

crates/bevy_ecs/src/schedule/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ mod tests {
12371237

12381238
/// verify the [`SimpleExecutor`] supports stepping
12391239
#[test]
1240+
#[expect(deprecated, reason = "We still need to test this.")]
12401241
fn simple_executor() {
12411242
assert_executor_supports_stepping!(ExecutorKind::Simple);
12421243
}

crates/bevy_ecs/src/schedule/schedule.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ impl Schedules {
218218

219219
fn make_executor(kind: ExecutorKind) -> Box<dyn SystemExecutor> {
220220
match kind {
221+
#[expect(deprecated, reason = "We still need to support this.")]
221222
ExecutorKind::Simple => Box::new(SimpleExecutor::new()),
222223
ExecutorKind::SingleThreaded => Box::new(SingleThreadedExecutor::new()),
223224
#[cfg(feature = "std")]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Deprecated Simple Executor
3+
pull_requests: [18753]
4+
---
5+
6+
Bevy has deprecated `SimpleExecutor`, one of the `SystemExecutor`s in Bevy alongside `SingleThreadedExecutor` and `MultiThreadedExecutor` (which aren't going anywhere any time soon).
7+
8+
The `SimpleExecutor` leaves performance on the table compared to the other executors in favor of simplicity.
9+
Specifically, `SimpleExecutor` applies any commands a system produces right after it finishes, so every system starts with a clean `World` with no pending commands.
10+
As a result, the default `SimpleExecutor` runs all systems in the order they are added to the schedule, though more ordering constraints can be applied, like `before`, `after`, `chain`, etc.
11+
In other executors, these ordering onstraints also inform the executor exactly where to apply commands.
12+
For example, if system `A` produces commands and runs `before` system `B`, `A`'s commands will be applied before `B` starts.
13+
However, the `before` ordering is implicit in `SimpleExecutor` if `A` is added to the schedule before `B`.
14+
15+
The dueling behavior between ordering systems based on when they were added to a schedule as opposed to using ordering constraints is difficult to maintain and can be confusing, especially for new users.
16+
But, if you have a strong preference for the existing behavior of `SimpleExecutor`, please make an issue and we can discuss your needs.
17+
18+
If you were using `SimpleExecutor`, consider upgrading to `SingleThreadedExecutor` instead, or try `MultiThreadedExecutor` if it fits the schedule.
19+
The `MultiThreadedExecutor` is great at large schedules and async heavy work, and the `SingleThreadedExecutor` is good at smaller schedules or schedules that have fewer parallelizable systems.
20+
So what was `SimpleExecutor` good at? Not much. That's why we plan to remove it. Removing it will reduce some maintenance and consistency burdens, allowing us to focus on more exciting features!
21+
22+
When migrating, you might uncover bugs where one system depends on another's commands but is not ordered to reflect that.
23+
These bugs can be fixed by making those implicit orderings explicit via constraints like `before`, `after`, `chain`, etc.
24+
If finding all of those implicit but necessary orderings is unrealistic, `chain` can also be used to mimic the behavior of the `SimpleExecutor`.
25+
Again, if you run into trouble migrating, feel free to open an issue!

0 commit comments

Comments
 (0)