feat: add some additional perf counters
This commit is contained in:
committed by
Sébastien Crozet
parent
e69e73e589
commit
9964007269
@@ -182,6 +182,12 @@ measure_method!(
|
||||
stages.solver_time
|
||||
);
|
||||
measure_method!(ccd_started, ccd_completed, ccd_time, stages.ccd_time);
|
||||
measure_method!(
|
||||
query_pipeline_update_started,
|
||||
query_pipeline_update_completed,
|
||||
query_pipeline_update_time,
|
||||
stages.query_pipeline_time
|
||||
);
|
||||
|
||||
measure_method!(
|
||||
assembly_started,
|
||||
@@ -201,12 +207,6 @@ measure_method!(
|
||||
velocity_update_time,
|
||||
solver.velocity_update_time
|
||||
);
|
||||
measure_method!(
|
||||
position_resolution_started,
|
||||
position_resolution_completed,
|
||||
position_resolution_time,
|
||||
solver.position_resolution_time
|
||||
);
|
||||
measure_method!(
|
||||
broad_phase_started,
|
||||
broad_phase_completed,
|
||||
|
||||
@@ -14,10 +14,8 @@ pub struct SolverCounters {
|
||||
pub velocity_assembly_time: Timer,
|
||||
/// Time spent for the update of the velocity of the bodies.
|
||||
pub velocity_update_time: Timer,
|
||||
/// Time spent for the assembly of all the position constraints.
|
||||
pub position_assembly_time: Timer,
|
||||
/// Time spent for the update of the position of the bodies.
|
||||
pub position_resolution_time: Timer,
|
||||
/// Time spent to write force back to user-accessible data.
|
||||
pub velocity_writeback_time: Timer,
|
||||
}
|
||||
|
||||
impl SolverCounters {
|
||||
@@ -29,8 +27,7 @@ impl SolverCounters {
|
||||
velocity_assembly_time: Timer::new(),
|
||||
velocity_resolution_time: Timer::new(),
|
||||
velocity_update_time: Timer::new(),
|
||||
position_assembly_time: Timer::new(),
|
||||
position_resolution_time: Timer::new(),
|
||||
velocity_writeback_time: Timer::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +38,7 @@ impl SolverCounters {
|
||||
self.velocity_resolution_time.reset();
|
||||
self.velocity_assembly_time.reset();
|
||||
self.velocity_update_time.reset();
|
||||
self.position_assembly_time.reset();
|
||||
self.position_resolution_time.reset();
|
||||
self.velocity_writeback_time.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,11 +53,10 @@ impl Display for SolverCounters {
|
||||
self.velocity_resolution_time
|
||||
)?;
|
||||
writeln!(f, "Velocity update time: {}", self.velocity_update_time)?;
|
||||
writeln!(f, "Position assembly time: {}", self.position_assembly_time)?;
|
||||
writeln!(
|
||||
f,
|
||||
"Position resolution time: {}",
|
||||
self.position_resolution_time
|
||||
"Velocity writeback time: {}",
|
||||
self.velocity_writeback_time
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ pub struct StagesCounters {
|
||||
pub solver_time: Timer,
|
||||
/// Total time spent for CCD and CCD resolution.
|
||||
pub ccd_time: Timer,
|
||||
/// Total time spent updating the query pipeline (if provided to `PhysicsPipeline::step`).
|
||||
pub query_pipeline_time: Timer,
|
||||
/// Total time spent propagating user changes.
|
||||
pub user_changes: Timer,
|
||||
}
|
||||
|
||||
impl StagesCounters {
|
||||
@@ -25,6 +29,8 @@ impl StagesCounters {
|
||||
island_construction_time: Timer::new(),
|
||||
solver_time: Timer::new(),
|
||||
ccd_time: Timer::new(),
|
||||
query_pipeline_time: Timer::new(),
|
||||
user_changes: Timer::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +41,8 @@ impl StagesCounters {
|
||||
self.island_construction_time.reset();
|
||||
self.solver_time.reset();
|
||||
self.ccd_time.reset();
|
||||
self.query_pipeline_time.reset();
|
||||
self.user_changes.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +60,8 @@ impl Display for StagesCounters {
|
||||
self.island_construction_time
|
||||
)?;
|
||||
writeln!(f, "Solver time: {}", self.solver_time)?;
|
||||
writeln!(f, "CCD time: {}", self.ccd_time)
|
||||
writeln!(f, "CCD time: {}", self.ccd_time)?;
|
||||
writeln!(f, "Query pipeline time: {}", self.query_pipeline_time)?;
|
||||
writeln!(f, "User changes time: {}", self.user_changes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ impl IslandSolver {
|
||||
joint_indices: &[JointIndex],
|
||||
multibodies: &mut MultibodyJointSet,
|
||||
) {
|
||||
counters.solver.velocity_resolution_time.resume();
|
||||
counters.solver.velocity_assembly_time.resume();
|
||||
let num_solver_iterations = base_params.num_solver_iterations.get()
|
||||
+ islands.active_island_additional_solver_iterations(island_id);
|
||||
|
||||
@@ -76,8 +76,10 @@ impl IslandSolver {
|
||||
&mut self.contact_constraints,
|
||||
&mut self.joint_constraints,
|
||||
);
|
||||
counters.solver.velocity_assembly_time.pause();
|
||||
|
||||
// SOLVE
|
||||
counters.solver.velocity_resolution_time.resume();
|
||||
self.velocity_solver.solve_constraints(
|
||||
¶ms,
|
||||
num_solver_iterations,
|
||||
@@ -86,8 +88,10 @@ impl IslandSolver {
|
||||
&mut self.contact_constraints,
|
||||
&mut self.joint_constraints,
|
||||
);
|
||||
counters.solver.velocity_resolution_time.pause();
|
||||
|
||||
// WRITEBACK
|
||||
counters.solver.velocity_writeback_time.resume();
|
||||
self.joint_constraints.writeback_impulses(impulse_joints);
|
||||
self.contact_constraints.writeback_impulses(manifolds);
|
||||
self.velocity_solver.writeback_bodies(
|
||||
@@ -98,6 +102,6 @@ impl IslandSolver {
|
||||
bodies,
|
||||
multibodies,
|
||||
);
|
||||
counters.solver.velocity_resolution_time.pause();
|
||||
counters.solver.velocity_writeback_time.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ impl PhysicsPipeline {
|
||||
);
|
||||
narrow_phase.compute_contacts(
|
||||
integration_parameters.prediction_distance,
|
||||
integration_parameters.dt,
|
||||
bodies,
|
||||
colliders,
|
||||
impulse_joints,
|
||||
@@ -178,7 +179,6 @@ impl PhysicsPipeline {
|
||||
multibody_joints,
|
||||
integration_parameters.min_island_size,
|
||||
);
|
||||
self.counters.stages.island_construction_time.pause();
|
||||
|
||||
if self.manifold_indices.len() < islands.num_islands() {
|
||||
self.manifold_indices
|
||||
@@ -203,6 +203,7 @@ impl PhysicsPipeline {
|
||||
bodies,
|
||||
&mut self.joint_constraint_indices,
|
||||
);
|
||||
self.counters.stages.island_construction_time.pause();
|
||||
|
||||
self.counters.stages.update_time.resume();
|
||||
for handle in islands.active_dynamic_bodies() {
|
||||
@@ -421,6 +422,7 @@ impl PhysicsPipeline {
|
||||
self.counters.step_started();
|
||||
|
||||
// Apply some of delayed wake-ups.
|
||||
self.counters.stages.user_changes.start();
|
||||
for handle in impulse_joints
|
||||
.to_wake_up
|
||||
.drain(..)
|
||||
@@ -459,6 +461,7 @@ impl PhysicsPipeline {
|
||||
.copied()
|
||||
.filter(|h| colliders.get(*h).map(|c| !c.is_enabled()).unwrap_or(false)),
|
||||
);
|
||||
self.counters.stages.user_changes.pause();
|
||||
|
||||
// TODO: do this only on user-change.
|
||||
// TODO: do we want some kind of automatic inverse kinematics?
|
||||
@@ -486,12 +489,16 @@ impl PhysicsPipeline {
|
||||
);
|
||||
|
||||
if let Some(queries) = query_pipeline.as_deref_mut() {
|
||||
self.counters.stages.query_pipeline_time.start();
|
||||
queries.update_incremental(colliders, &modified_colliders, &removed_colliders, false);
|
||||
self.counters.stages.query_pipeline_time.pause();
|
||||
}
|
||||
|
||||
self.counters.stages.user_changes.resume();
|
||||
self.clear_modified_colliders(colliders, &mut modified_colliders);
|
||||
self.clear_modified_bodies(bodies, &mut modified_bodies);
|
||||
removed_colliders.clear();
|
||||
self.counters.stages.user_changes.pause();
|
||||
|
||||
let mut remaining_time = integration_parameters.dt;
|
||||
let mut integration_parameters = *integration_parameters;
|
||||
@@ -508,7 +515,7 @@ impl PhysicsPipeline {
|
||||
// the timestep into multiple intervals. First, estimate the
|
||||
// size of the time slice we will integrate for this substep.
|
||||
//
|
||||
// Note that we must do this now, before the constrains resolution
|
||||
// Note that we must do this now, before the constraints resolution
|
||||
// because we need to use the correct timestep length for the
|
||||
// integration of external forces.
|
||||
//
|
||||
@@ -599,7 +606,9 @@ impl PhysicsPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
self.counters.stages.update_time.resume();
|
||||
self.advance_to_final_positions(islands, bodies, colliders, &mut modified_colliders);
|
||||
self.counters.stages.update_time.pause();
|
||||
|
||||
self.detect_collisions(
|
||||
&integration_parameters,
|
||||
@@ -618,12 +627,14 @@ impl PhysicsPipeline {
|
||||
);
|
||||
|
||||
if let Some(queries) = query_pipeline.as_deref_mut() {
|
||||
self.counters.stages.query_pipeline_time.resume();
|
||||
queries.update_incremental(
|
||||
colliders,
|
||||
&modified_colliders,
|
||||
&[],
|
||||
remaining_substeps == 0,
|
||||
);
|
||||
self.counters.stages.query_pipeline_time.pause();
|
||||
}
|
||||
|
||||
self.clear_modified_colliders(colliders, &mut modified_colliders);
|
||||
@@ -635,10 +646,12 @@ impl PhysicsPipeline {
|
||||
// TODO: avoid updating the world mass properties twice (here, and
|
||||
// at the beginning of the next timestep) for bodies that were
|
||||
// not modified by the user in the mean time.
|
||||
self.counters.stages.update_time.resume();
|
||||
for handle in islands.active_dynamic_bodies() {
|
||||
let rb = bodies.index_mut_internal(*handle);
|
||||
rb.mprops.update_world_mass_properties(&rb.pos.position);
|
||||
}
|
||||
self.counters.stages.update_time.pause();
|
||||
|
||||
self.counters.step_completed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user