Skip to content

Rebuild faster after an annotation-only edit: reuse fixed-ink face meshes across rebuilds #2207

Closed

Description

@pzfreo

Context

We're scoping a graphical editor for Draftwright drawings in Draftwright.io: click an annotation, move it a lane or a side, remove it, and so on. Each edit replays the Sheet script. With rc9, I profiled replays of two Specify outputs (https://gist.github.com/pzfreo/7c6a0be95a567e2774924207133b2d40; the scripts come from generate_sheet_script(..., pmi='annotate')).

annotations/_leader_fixed_ink.py:_validated_face_mesh tessellates projected view faces for leader fixed-ink checks:

Build Calls Time Distinct (face, tolerance)
Plate, automatic (2 layout passes) 1,200 9.5 s —
Plate, scale and page pinned (1 pass) 600 4.3 s of a 30.5 s build 550
Spindle 286 — 254

So a memo within one build barely helps: the faces are mostly distinct. But these are faces of the projected views, which an annotation-only edit (layout_override, place(lane=...), removing a dimension) doesn't change at the same scale and page.

Proposal

Let a caller carry a mesh cache across rebuilds of the same part, scale and views. For example, a public cache object passed to Sheet.build(), keyed on the projected face geometry and the tolerance, and dropped when the scale, page or views change. Alternatively, key it on a stable projection identity, if one exists internally.

Expected gain

About 4 s of a 30 s pinned plate rebuild, and proportionally less on simpler parts. It's worth having for interactive edits, but per-view relayout is the larger lever.

Activity

  1. pzfreo commented on Oct 6, 2026

    @pzfreo
    OwnerAuthor

    Investigation correction: _validated_face_mesh is called on annotation.faces() in the fixed-ink inventory and final leader validation, not only on projected part-view faces. An annotation-only edit can therefore change these faces while part/scale/views stay fixed. A cache keyed only by those three inputs would be unsafe. I am testing a caller-held, bounded cache keyed by exact serialized face B-rep plus tessellation tolerance; malformed/unserializable faces must fall back to the current validation path. A tiny identical-Leader check showed exact B-rep keys stable across constructions and cheaper to compute than tessellation, but it is not a corpus speedup measurement yet.

  2. pzfreo commented on Oct 6, 2026

    @pzfreo
    OwnerAuthor

    PR #2217 implements the safe opt-in cache and has auto-merge armed for green CI. A small authored-bore replay reused 12/12 validated face meshes on the second build without changing annotation inventory or lint; this establishes reuse, not the proposed 4-second plate saving. I am keeping the issue open pending a representative pinned-plate timing check.

  3. pzfreo commented on Oct 6, 2026

    @pzfreo
    OwnerAuthor

    Representative local replay measurement on the PMI-enabled Specify plate Sheet script, pinned A1 at 1:1/permissive (51 annotations): cache cold build 22.0 s with 568 misses; cached repeat 18.1 s with 583 hits/1 miss. In a separate process, uncached first/warm builds were 21.9/25.6 s. These are single-run wall times, so the exact gain is noisy, but the 583 avoided tessellations and unchanged annotation count show the intended reuse on this workload. PR #2217 remains gated by required CI.

  4. pzfreo commented on Oct 7, 2026

    @pzfreo
    OwnerAuthor

    Measured the opt-in cache PR #2217 on the local GRM04 drive-plate STEP with a reused Sheet and identical drawing/lint signatures. In one process, cached cold build: 7.361 s (281 misses); cached warm replay: 5.785 s (280 hits, 1 additional miss); uncached warm replay: 6.990 s. That is an indicative 1.205 s / 17% warm-replay saving on this corpus plate, separating cache reuse from ordinary warm-up. An earlier two-pass run was 10.249 s cold and 7.310 s warm, so absolute timing varies. This is not yet the rc9 Specify plate from the issue; keep the issue open until that representative script is retimed after merge.

  5. pzfreo commented on Oct 7, 2026

    @pzfreo
    OwnerAuthor

    Retimed the exact public Specify plate specimen from the linked gist, using a freshly generated pmi="annotate" Sheet script on this PR branch (#2217). In one process on the same Sheet: cached cold build 32.537 s (599 hits / 569 misses, including reuse across its automatic layout passes); cached warm replay 26.540 s (1,168 further hits, zero further misses); uncached warm replay 39.146 s. Cached warm was 12.606 s / 32% faster than the uncached warm control in this single run. All three yielded the same 51 annotation names and the same 13 lint code/severity pairs. This is representative evidence for the reported plate, though timing is one run and not a formal benchmark. The issue can close after #2217 lands and its CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions