Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the system task span #12950

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 1 addition & 23 deletions crates/bevy_ecs/src/schedule/executor/multi_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ struct SystemTaskMetadata {
is_send: bool,
/// Is `true` if the system is exclusive.
is_exclusive: bool,
/// Cached tracing span for system task
#[cfg(feature = "trace")]
system_task_span: Span,
}

/// The result of running a system that is sent across a channel.
Expand Down Expand Up @@ -177,11 +174,6 @@ impl SystemExecutor for MultiThreadedExecutor {
dependents: schedule.system_dependents[index].clone(),
is_send: schedule.systems[index].is_send(),
is_exclusive: schedule.systems[index].is_exclusive(),
#[cfg(feature = "trace")]
system_task_span: info_span!(
"system_task",
name = &*schedule.systems[index].name()
),
});
}

Expand Down Expand Up @@ -610,12 +602,8 @@ impl ExecutorState {

let system_meta = &self.system_task_metadata[system_index];

#[cfg(feature = "trace")]
let system_span = system_meta.system_task_span.clone();
let task = async move {
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
#[cfg(feature = "trace")]
let _span = system_span.enter();
// SAFETY:
// - The caller ensures that we have permission to
// access the world data used by the system.
Expand Down Expand Up @@ -651,30 +639,20 @@ impl ExecutorState {
let system = unsafe { &mut *context.environment.systems[system_index].get() };
// Move the full context object into the new future.
let context = *context;
#[cfg(feature = "trace")]
let system_span = self.system_task_metadata[system_index]
.system_task_span
.clone();

if is_apply_deferred(system) {
// TODO: avoid allocation
let unapplied_systems = self.unapplied_systems.clone();
self.unapplied_systems.clear();
let task = async move {
let res = {
#[cfg(feature = "trace")]
let _span = system_span.enter();
apply_deferred(&unapplied_systems, context.environment.systems, world)
};
let res = apply_deferred(&unapplied_systems, context.environment.systems, world);
context.system_completed(system_index, res, system);
};

context.scope.spawn_on_scope(task);
} else {
let task = async move {
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
#[cfg(feature = "trace")]
let _span = system_span.enter();
__rust_begin_short_backtrace::run(&mut **system, world);
}));
context.system_completed(system_index, res, system);
Expand Down