perf: look the draw depth up only where it is used

`arena-post partition=55.2ms blocks=5.9ms curves=2.5ms` — the partition is
the whole of the 73 ms an arena patch spends after patching, and it runs
on every drawn point over the entire resident set.

Inside it, `wire_draw_depth` is a hash lookup whose result feeds only the
analytical circle and ellipse extraction, and it was computed before the
test that decides whether either will run. So every patch paid 236 956
lookups to serve the ~56 000 wires that are circles or ellipses.

Moving it inside that branch is behaviour-preserving: the value was
unused on every path that skipped it.

This does not make the partition incremental — it still walks the resident
set for a one-entity change — but that walk is memory-bound and a
structural fix needs the cached partition to survive a patch, which the
borrows in `PartitionedWires` make its own piece of work.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
PanosandClaude Opus 5 committed 2026-09-08 16:42:38 +03:00
1 parent feb3ca4d28
commit b68989768d
1 file changed
+5 -1
+5 -1
View File
@@ -199,12 +199,16 @@ pub fn partition_wires<'a>(
instanced.push(wire);
continue;
}
let depth = super::wire_gpu::wire_draw_depth(wire, depth_map);
// `wire_draw_depth` is a hash lookup and its result is used only by the
// analytical extractions below, which most wires never reach. Computing
// it first cost one lookup per resident wire on every patch — 236 956
// of them for the ~56 000 that are circles or ellipses.
if !wire.tangent_geoms.is_empty()
&& wire.fill_tris.is_empty()
&& wire.pick_tris.is_empty()
&& wire.text_verts.is_empty()
{
let depth = super::wire_gpu::wire_draw_depth(wire, depth_map);
if let Some(insts) = super::circle_gpu::extract_circle_instances(wire, depth) {
circle_instances.extend(insts);
continue;