ecs: add some spans around the system executors
ci/woodpecker/push/debug Pipeline failed Details

This commit is contained in:
SeanOMik 2024-04-01 12:02:16 -04:00
parent f3b5106073
commit 3dfb2520ce
Signed by: SeanOMik
GPG Key ID: FEC9E2FC15235964
5 changed files with 27 additions and 1 deletions

1
Cargo.lock generated
View File

@ -1758,6 +1758,7 @@ dependencies = [
"paste",
"rand 0.8.5",
"thiserror",
"tracing",
]
[[package]]

View File

@ -15,6 +15,7 @@ anyhow = "1.0.75"
thiserror = "1.0.50"
paste = "1.0.14"
atomic_refcell = "0.1.13"
tracing = "0.1.37"
[dev-dependencies]
rand = "0.8.5" # used for tests

View File

@ -1,4 +1,5 @@
use lyra_ecs::World;
use tracing::debug_span;
use crate::Access;
@ -51,6 +52,9 @@ impl System for BatchedSystem {
let mut check_again = false;
for criteria in self.criteria.iter_mut() {
let crit_span = debug_span!("criteria");
let _e = crit_span.enter();
match criteria.can_run(world, self.criteria_checks) {
super::CriteriaSchedule::Yes => {},
super::CriteriaSchedule::No => can_run = false,
@ -65,7 +69,11 @@ impl System for BatchedSystem {
}
if can_run {
for system in self.systems.iter_mut() {
for (idx, system) in self.systems.iter_mut().enumerate() {
let sys_span = debug_span!("batch", system=tracing::field::Empty);
sys_span.record("system", idx);
let _e = sys_span.enter();
system.execute(world)?;
}
}

View File

@ -1,5 +1,7 @@
use std::{collections::{HashMap, VecDeque, HashSet}, ptr::NonNull};
use tracing::{debug_span, info_span};
use super::System;
use crate::{World, CommandQueue, Commands};
@ -69,9 +71,14 @@ impl GraphExecutor {
let mut possible_errors = Vec::new();
let sys_span = info_span!("graph_exec", system=tracing::field::Empty);
while let Some(node) = stack.pop_front() {
let system = self.systems.get_mut(node.as_str()).unwrap();
sys_span.record("system", system.name.clone());
let _e = sys_span.enter();
if let Err(e) = system.system.execute(world_ptr)
.map_err(|e| GraphExecutorError::SystemError(node, e)) {
if stop_on_error {
@ -82,6 +89,9 @@ impl GraphExecutor {
unimplemented!("Cannot resume topological execution from error"); // TODO: resume topological execution from error
}
let deferred_span = debug_span!("deferred_exec");
let _e = deferred_span.enter();
if let Err(e) = system.system.execute_deferred(world_ptr)
.map_err(|e| GraphExecutorError::Command(e)) {

View File

@ -1,6 +1,7 @@
use std::{hash::{Hash, DefaultHasher, Hasher}, collections::{HashMap, HashSet, VecDeque}, ptr::NonNull, fmt::Debug};
use lyra_ecs::{system::{GraphExecutor, GraphExecutorError, System}, World};
use tracing::info_span;
#[derive(thiserror::Error, Debug)]
pub enum StagedExecutorError {
@ -119,10 +120,15 @@ impl StagedExecutor {
self.topological_sort(&mut stack, &mut visited, node)?;
}
let stage_span = info_span!("stage_exec", stage=tracing::field::Empty);
let mut errors = vec![];
while let Some(node) = stack.pop_front() {
let stage = self.stages.get_mut(&node).unwrap();
stage_span.record("stage", stage.name.clone());
let _e = stage_span.enter();
if let Err(e) = stage.exec.execute(world, stop_on_error) {
let e = StagedExecutorError::from_graph_error(stage.name.clone(), e);