forked from 1b-agent/opencadstudio-upstream
perf: instrument the file-open load path behind PERF
The 52 s silent stretch in a large-DWG open could not be attributed:
OpenTimings covered parse / purge / xref / caches, but the FINALIZING
phase -- prepare_open_geometry, which does the first full Model
tessellation and builds the interaction index -- was unmeasured and
reports only two progress ticks, so it was indistinguishable from parse
time.
Add finalize_ms to OpenTimings and a per-stage PERF breakdown:
open-phases parse / purge / xref / caches / finalize
open-finalize tessellation vs interaction index
open-index index build vs prepare_screen
wires-build sort cache, visible filter, block cache, classify,
memo hits, parallel tessellate, materialize, sort
resident-post scene markers, refedit fade, resident layout
wire-upload build_wire_buffers, which runs on the render thread
The wires-build line separates the parallel tessellate from the serial
materialize loop that deep-clones every WireModel while the memo retains
a second copy -- the leading hypothesis for both the stall and the
6.45 GB RSS.
No behaviour change. Every timer is gated on crate::perf::enabled(), so
nothing runs without PERF=1 or the in-app PERF panel. The localized
open-summary format string is left alone; changing it would rekey the
string across every locale, so the full breakdown goes to PERF instead.
Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
886d5777d8
commit
2787dcc1a3
4 files changed
+137
-2
No files matched your search
@@ -383,6 +383,8 @@ async fn open_path_with_phase_attempt(
|
||||
purge_ms,
|
||||
caches_ms: t_caches.elapsed().as_millis() as u32,
|
||||
xref_ms,
|
||||
// Filled in after `prepare_open_geometry` below.
|
||||
finalize_ms: 0,
|
||||
};
|
||||
caches.corrupt_dropped = dropped;
|
||||
caches.read_stats = Some(read_stats);
|
||||
@@ -395,11 +397,24 @@ async fn open_path_with_phase_attempt(
|
||||
);
|
||||
}
|
||||
progress2.set(crate::app::OPEN_PHASE_FINALIZING, 9600, 0, 1);
|
||||
let t_finalize = Instant::now();
|
||||
let (prepared_doc, prepared_geometry) =
|
||||
crate::scene::prepare_open_geometry(doc, &caches, model_bg);
|
||||
caches.timings.finalize_ms = t_finalize.elapsed().as_millis() as u32;
|
||||
doc = prepared_doc;
|
||||
caches.prepared_geometry = Some(prepared_geometry);
|
||||
progress2.set(crate::app::OPEN_PHASE_FINALIZING, 9950, 1, 1);
|
||||
// The localized command-line summary predates `finalize_ms` and
|
||||
// is keyed on its format string, so the full breakdown goes out
|
||||
// here instead of changing that key across every locale.
|
||||
crate::perf_record!(
|
||||
"[perf] open-phases parse={}ms purge={}ms xref={}ms caches={}ms finalize={}ms",
|
||||
caches.timings.parse_ms,
|
||||
caches.timings.purge_ms,
|
||||
caches.timings.xref_ms,
|
||||
caches.timings.caches_ms,
|
||||
caches.timings.finalize_ms,
|
||||
);
|
||||
Ok((doc, caches))
|
||||
})()
|
||||
}));
|
||||
|
||||
@@ -373,6 +373,7 @@ impl RecoveryReport {
|
||||
lines.push(format!("Validation: {} ms", self.timings.purge_ms));
|
||||
lines.push(format!("References: {} ms", self.timings.xref_ms));
|
||||
lines.push(format!("Scene caches: {} ms", self.timings.caches_ms));
|
||||
lines.push(format!("Geometry prep: {} ms", self.timings.finalize_ms));
|
||||
lines.push(format!("Total: {} ms", self.total_ms));
|
||||
if !self.diagnostics.is_empty() {
|
||||
lines.push(String::new());
|
||||
|
||||
Reference in new issue
Block a user