Expose CSG incremental rebuild strategy
This commit is contained in:
parent
951c3abba8
commit
06b266b0bd
3 changed files with 44 additions and 3 deletions
|
|
@ -134,7 +134,9 @@ Mesh reuse seam: incremental rebuilds now keep the previous generation's cached
|
|||
mesh and reuse it only when suffix replay proves no geometry was touched. This
|
||||
is intentionally exact and conservative: distant rejected edits can skip mesh
|
||||
emission, while candidate cuts still emit the full output mesh. The report
|
||||
exposes `reused_mesh` so the fixture and tests do not infer reuse from timing.
|
||||
exposes `reused_mesh`, `used_checkpoint`, `checkpoint_rebuild_from`, and
|
||||
`direct_dirty_rebuild` so the fixture and tests do not infer rebuild strategy
|
||||
from timing.
|
||||
|
||||
Benchmark correction: `rebuild()` must bypass checkpoint caches. An earlier
|
||||
fixture pass accidentally let the dirty box baseline travel through cached box
|
||||
|
|
@ -217,3 +219,10 @@ replay. The checkpoint path still wins hard for general convex tail edits:
|
|||
and `common_box_chain_64` stays far below full dirty rebuild. Rejected general
|
||||
convex suffixes can expose `reused_mesh:true`; the fixture includes
|
||||
`distant_oriented_cutters_128` for that case.
|
||||
|
||||
Planning counters now expose rebuild strategy. Treat `direct_dirty_rebuild:true`
|
||||
as a sign the incremental planner deliberately bailed to the direct path.
|
||||
Treat `used_checkpoint:true` and `checkpoint_rebuild_from` as evidence of a live
|
||||
suffix replay boundary. Treat `reused_mesh:true` as proof that suffix replay did
|
||||
not touch geometry and reused the previous output mesh. These fields are part of
|
||||
the benchmark contract because timings alone already lied once.
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ fn run_case(case: PerfCase, mode: PerfMode) {
|
|||
let mut candidate_pairs = 0;
|
||||
let mut rejected_pairs = 0;
|
||||
let mut reused_mesh = false;
|
||||
let mut used_checkpoint = false;
|
||||
let mut checkpoint_rebuild_from = None::<usize>;
|
||||
let mut direct_dirty_rebuild = false;
|
||||
|
||||
for iteration in 0..MEASURE_ITERS {
|
||||
let start = Instant::now();
|
||||
|
|
@ -127,6 +130,9 @@ fn run_case(case: PerfCase, mode: PerfMode) {
|
|||
candidate_pairs = output.report.candidate_pairs;
|
||||
rejected_pairs = output.report.rejected_pairs;
|
||||
reused_mesh = output.report.reused_mesh;
|
||||
used_checkpoint = output.report.used_checkpoint;
|
||||
checkpoint_rebuild_from = output.report.checkpoint_rebuild_from;
|
||||
direct_dirty_rebuild = output.report.direct_dirty_rebuild;
|
||||
black_box((
|
||||
triangles,
|
||||
fragments,
|
||||
|
|
@ -134,6 +140,9 @@ fn run_case(case: PerfCase, mode: PerfMode) {
|
|||
candidate_pairs,
|
||||
rejected_pairs,
|
||||
reused_mesh,
|
||||
used_checkpoint,
|
||||
checkpoint_rebuild_from,
|
||||
direct_dirty_rebuild,
|
||||
));
|
||||
timings.push(elapsed);
|
||||
}
|
||||
|
|
@ -149,7 +158,7 @@ fn run_case(case: PerfCase, mode: PerfMode) {
|
|||
let p95_ns = percentile_ns(&timings, 95);
|
||||
|
||||
println!(
|
||||
"{{\"kernel\":\"vg_csg\",\"mode\":\"{}\",\"scenario\":\"{}\",\"brushes\":{},\"iterations\":{},\"warmup_iterations\":{},\"mean_ns\":{},\"min_ns\":{},\"p50_ns\":{},\"p95_ns\":{},\"max_ns\":{},\"triangles\":{},\"fragments\":{},\"warnings\":{},\"candidate_pairs\":{},\"rejected_pairs\":{},\"reused_mesh\":{}}}",
|
||||
"{{\"kernel\":\"vg_csg\",\"mode\":\"{}\",\"scenario\":\"{}\",\"brushes\":{},\"iterations\":{},\"warmup_iterations\":{},\"mean_ns\":{},\"min_ns\":{},\"p50_ns\":{},\"p95_ns\":{},\"max_ns\":{},\"triangles\":{},\"fragments\":{},\"warnings\":{},\"candidate_pairs\":{},\"rejected_pairs\":{},\"reused_mesh\":{},\"used_checkpoint\":{},\"checkpoint_rebuild_from\":{},\"direct_dirty_rebuild\":{}}}",
|
||||
mode.as_str(),
|
||||
case.name,
|
||||
case.brushes,
|
||||
|
|
@ -165,7 +174,10 @@ fn run_case(case: PerfCase, mode: PerfMode) {
|
|||
warnings,
|
||||
candidate_pairs,
|
||||
rejected_pairs,
|
||||
reused_mesh
|
||||
reused_mesh,
|
||||
used_checkpoint,
|
||||
checkpoint_rebuild_from.map_or_else(|| "null".to_string(), |index| index.to_string()),
|
||||
direct_dirty_rebuild
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ pub struct BuildReport {
|
|||
pub candidate_pairs: usize,
|
||||
pub rejected_pairs: usize,
|
||||
pub reused_mesh: bool,
|
||||
pub used_checkpoint: bool,
|
||||
pub checkpoint_rebuild_from: Option<usize>,
|
||||
pub direct_dirty_rebuild: bool,
|
||||
pub warnings: Vec<BuildWarning>,
|
||||
}
|
||||
|
||||
|
|
@ -442,6 +445,7 @@ impl Assembler {
|
|||
for brush in &self.compiled {
|
||||
state.apply_compiled_box(brush);
|
||||
}
|
||||
state.report.direct_dirty_rebuild = true;
|
||||
state.into_output_with_mesh(self.brushes.len(), self.generation, None)
|
||||
}
|
||||
|
||||
|
|
@ -488,6 +492,10 @@ impl Assembler {
|
|||
} else {
|
||||
(BoxBuildState::default(), 0)
|
||||
};
|
||||
if start_index > 0 {
|
||||
state.report.used_checkpoint = true;
|
||||
state.report.checkpoint_rebuild_from = Some(start_index);
|
||||
}
|
||||
|
||||
let mut checkpoints = (start_index == 0).then(|| vec![BoxBuildState::default()]);
|
||||
|
||||
|
|
@ -544,6 +552,10 @@ impl Assembler {
|
|||
} else {
|
||||
(GeneralBuildState::default(), 0)
|
||||
};
|
||||
if start_index > 0 {
|
||||
state.report.used_checkpoint = true;
|
||||
state.report.checkpoint_rebuild_from = Some(start_index);
|
||||
}
|
||||
|
||||
let mut checkpoints = (start_index == 0).then(|| vec![GeneralBuildState::default()]);
|
||||
|
||||
|
|
@ -1300,6 +1312,8 @@ mod tests {
|
|||
let incremental = asm.build_incremental();
|
||||
let full = asm.rebuild();
|
||||
|
||||
assert!(!incremental.report.used_checkpoint);
|
||||
assert!(incremental.report.direct_dirty_rebuild);
|
||||
assert_eq!(incremental.mesh.positions, full.mesh.positions);
|
||||
assert_eq!(incremental.mesh.indices, full.mesh.indices);
|
||||
assert_eq!(
|
||||
|
|
@ -1385,6 +1399,9 @@ mod tests {
|
|||
|
||||
assert_eq!(after.mesh, before.mesh);
|
||||
assert!(after.report.reused_mesh);
|
||||
assert!(after.report.used_checkpoint);
|
||||
assert_eq!(after.report.checkpoint_rebuild_from, Some(1));
|
||||
assert!(!after.report.direct_dirty_rebuild);
|
||||
assert_eq!(after.report.candidate_pairs, 0);
|
||||
assert_eq!(after.report.rejected_pairs, 1);
|
||||
}
|
||||
|
|
@ -1422,6 +1439,9 @@ mod tests {
|
|||
let incremental = asm.build_incremental();
|
||||
let full = asm.rebuild();
|
||||
|
||||
assert!(incremental.report.used_checkpoint);
|
||||
assert_eq!(incremental.report.checkpoint_rebuild_from, Some(12));
|
||||
assert!(!incremental.report.direct_dirty_rebuild);
|
||||
assert_eq!(incremental.mesh.positions, full.mesh.positions);
|
||||
assert_eq!(incremental.mesh.indices, full.mesh.indices);
|
||||
assert_eq!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue