forked from 1b-agent/opencadstudio-upstream
perf: say which message caused an edit's latency
The first measurement showed four consecutive edits at ~192 ms each with a handler cost of 0.55 ms. That is below the `update` line's 5 ms threshold, so the log reports the latency but not what asked for it — and whether a live command preview is bumping the geometry epoch on every mouse move is exactly the question the numbers raise. `nav-prepare` now carries the message label alongside the op. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b4ae4cad4e
commit
d267083a29
3 files changed
+21
-3
No files matched your search
@@ -334,8 +334,11 @@ impl OpenCADStudio {
|
|||||||
if let (Some(started), Some(before)) = (perf_started, perf_epoch_before) {
|
if let (Some(started), Some(before)) = (perf_started, perf_epoch_before) {
|
||||||
let tab = &self.tabs[self.active_tab];
|
let tab = &self.tabs[self.active_tab];
|
||||||
if tab.scene.geometry_epoch != before {
|
if tab.scene.geometry_epoch != before {
|
||||||
tab.scene
|
tab.scene.record_nav_perf_caused(
|
||||||
.record_nav_perf(crate::scene::NavPerfOp::Edit, started);
|
crate::scene::NavPerfOp::Edit,
|
||||||
|
perf_label,
|
||||||
|
started,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(started) = perf_started {
|
if let Some(started) = perf_started {
|
||||||
|
|||||||
@@ -1452,6 +1452,10 @@ impl NavPerfOp {
|
|||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub(in crate::scene) struct NavPerfSample {
|
pub(in crate::scene) struct NavPerfSample {
|
||||||
pub(in crate::scene) op: NavPerfOp,
|
pub(in crate::scene) op: NavPerfOp,
|
||||||
|
/// Which message caused it. An edit whose handler runs in under a
|
||||||
|
/// millisecond never reaches the `update` line's threshold, so without this
|
||||||
|
/// the log shows the latency but not what asked for it.
|
||||||
|
pub(in crate::scene) cause: &'static str,
|
||||||
pub(in crate::scene) space: &'static str,
|
pub(in crate::scene) space: &'static str,
|
||||||
pub(in crate::scene) mode: &'static str,
|
pub(in crate::scene) mode: &'static str,
|
||||||
pub(in crate::scene) started: iced::time::Instant,
|
pub(in crate::scene) started: iced::time::Instant,
|
||||||
@@ -2880,6 +2884,15 @@ impl Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn record_nav_perf(&self, op: NavPerfOp, started: iced::time::Instant) {
|
pub(crate) fn record_nav_perf(&self, op: NavPerfOp, started: iced::time::Instant) {
|
||||||
|
self.record_nav_perf_caused(op, "-", started);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn record_nav_perf_caused(
|
||||||
|
&self,
|
||||||
|
op: NavPerfOp,
|
||||||
|
cause: &'static str,
|
||||||
|
started: iced::time::Instant,
|
||||||
|
) {
|
||||||
if !crate::perf::enabled() {
|
if !crate::perf::enabled() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2892,6 +2905,7 @@ impl Scene {
|
|||||||
};
|
};
|
||||||
self.nav_perf_pending.set(Some(NavPerfSample {
|
self.nav_perf_pending.set(Some(NavPerfSample {
|
||||||
op,
|
op,
|
||||||
|
cause,
|
||||||
space,
|
space,
|
||||||
mode,
|
mode,
|
||||||
started,
|
started,
|
||||||
|
|||||||
@@ -1216,8 +1216,9 @@ impl shader::Primitive for Primitive {
|
|||||||
let prepare_ms = nav_prepare_started.elapsed().as_secs_f64() * 1000.0;
|
let prepare_ms = nav_prepare_started.elapsed().as_secs_f64() * 1000.0;
|
||||||
if let Some(sample) = self.nav_perf {
|
if let Some(sample) = self.nav_perf {
|
||||||
crate::perf::record(format_args!(
|
crate::perf::record(format_args!(
|
||||||
"[perf] nav-prepare op={} space={} mode={} input={:.2}ms build={:.2}ms prepare={:.2}ms elapsed={:.2}ms viewports={}",
|
"[perf] nav-prepare op={} cause={} space={} mode={} input={:.2}ms build={:.2}ms prepare={:.2}ms elapsed={:.2}ms viewports={}",
|
||||||
sample.op.label(),
|
sample.op.label(),
|
||||||
|
sample.cause,
|
||||||
sample.space,
|
sample.space,
|
||||||
sample.mode,
|
sample.mode,
|
||||||
sample.input_ms,
|
sample.input_ms,
|
||||||
|
|||||||
Reference in new issue
Block a user