Skip to content

tile_stepper: every phase counted by vertex, so a cooperative step stays near the slice - #1411

Merged
transfix merged 4 commits into
masterfrom
tiler/step-by-vertex
Nov 21, 2026
Merged

transfix merged 4 commits into
masterfrom
tiler/step-by-vertex

Conversation

@transfix

Copy link
Copy Markdown
Owner

cvc::tile_stepper now keeps each cooperative step near §1.9's 4 ms slice. P4 found the problem while measuring its demo (#1397): the first frames of a tile took 50 to 160 ms. This fixes the stepper only; the contour_lab node needs no change.

What was coarse

  • step(budget) ran on across a phase change, so a budget the scheduler had sized on "snapping" units (a vertex each) was spent on "curating" units.
  • A "curating" unit was a whole slice, and an "augmenting" unit a whole slice pair. Each cost milliseconds, and the scheduler's smallest call is 16 units.
  • Profiling found tiling coarse in the same way. Its units averaged 20 µs, many cost 0.1 to 0.5 ms, and an untiled region's fill was up to 18 ms in one piece. Each phase starts at 256 units, so tiling's first call ran about 5 ms.

The change

  • A step ends where the phase changes. Budget 0 still runs to the end.
  • Every phase is counted by vertex. Curating, augmenting and tiling yield one contour, pair of contours or test at a time.
    • A call that cannot yield is charged by the vertices it takes: a Clipper2 offset or Boolean, a sweep, a simplicity test, a Delaunay triangulation, a hierarchy, a workspace built or freed.
    • The charging is TILER_UNITS with its charges in src/cvc/geometry/tiler/stepping.h, calibrated to about a microsecond a unit.
  • An untiled region's fill yields a point at a time (medial_axis_stable_steps, interpolate_steps). The legacy functions run these to the end, as the other stages do.
  • Large frees are split. A slice pair's workspaces and the assembled triangles are freed a piece at a time.
  • No result changes. The order of the work is unchanged; only yields were added. T7 still finds results bit for bit equal at budgets 1, 64, random and 0.

Measured

Native MSVC Release, CVC_SLICED_THREADING=cooperative, 4 ms slice. These are three runs each on a shared machine.

Case Slowest step, default budget Slowest cooperative frame
P4's demo stack in cvcgl_contour_lab (3 components × 40 slices × 64 vertices) (job in the app) 4.1 to 4.7 ms per phase; was 50 to 160 ms
T7 touching / branch, P3b's build (before) 41 to 117 ms 6.1 to 8.7 ms
T7 touching / branch / P4's stack on 12 slices (after) 2.8 to 7.5 ms 4.1 to 5.0 ms
Same, wasm-mt node 4.0 to 7.1 ms 4.3 to 4.9 ms (touching 9.2 to 9.6)
Bunny (tiler_bunny_test, 50 slices, 9,536 vertices) 9 to 16 ms 5.6 to 5.8 ms (9.6 under load)
  • Blocking time. The blocking call takes as long as before, measured A/B against P3b's build. Stepping at the default budget costs 0 to 10% over budget 0.
  • What is still coarse.
    • Intersection removal between two components' tiles (remove_intersections, off by default) is one unit per pair of components. It is about 2 ms natively, and it is why touching reaches 9 ms under wasm.
    • On the bunny, single tiling tests and freed workspaces take up to 2 to 4 ms.
  • contour_lab's slowest frame is outside the stepper. It is the document's frame that starts the job (14 to 60 ms), not a step.

Tests

  • tiler_test (21, including a new T7 case on P4's stack), tiler_legacy_test (58) and tiler_intrinsics_test (9) pass natively and under wasm-mt node.
    • Locally on Windows, the node run of tiler_test embeds the committed inputs, because -sNODERAWFS cannot read the working tree there.
  • tiler_bunny_test passes. It now also records the bunny's slowest step and cooperative frame, using the T7 harness's timed and frame runs, which now run alone too.
  • cvcgl_contour_lab (57 checks) passes on contour_lab: the contour tiler in Ariadne, with a demo on a real Reconstruct series (P4) #1397's branch with this change applied.

Roadmap

§3's "Resumable" paragraph now describes the units and records the measurements above. #1397 adds a "Found in P4" paragraph to §3's Ariadne bullet that describes this problem. Whichever of the two PRs merges second should replace that paragraph with a pointer to "Resumable".

…ays near the slice

In cooperative mode the first frames of a tile took 50-160 ms against §1.9's 4 ms slice (found
in P4): step() ran on across a phase change, and a curating or augmenting unit was a whole slice
or slice pair.

- A step ends where the phase changes (budget 0 still runs to the end).
- Curating, augmenting and tiling yield a contour, pair of contours or test at a time, and a call
  that cannot yield (Clipper2, a sweep, a simplicity test, a Delaunay) is charged by the vertices
  it takes (TILER_UNITS, tiler/stepping.h), about a microsecond a unit.
- An untiled region's fill yields a point at a time (medial_axis_stable_steps, interpolate_steps);
  a slice pair's workspaces and the assembled triangles are freed a piece at a time.
- The order of the work is unchanged: T7 still finds every budget's result bit for bit equal.

Tests: tiler_test's T7 on P4's demo stack (3 components x 12 slices x 64 vertices), and
tiler_bunny_test records the bunny's slowest step and cooperative frame (the harness's timed and
frame runs now run alone too).
@transfix
transfix merged commit 85beb8f into master Nov 21, 2026
29 checks passed
@transfix
transfix deleted the tiler/step-by-vertex branch November 21, 2026 05:42
transfix added a commit that referenced this pull request Nov 21, 2026
…e, now that #1411 fixed it (#1419)

#1397 recorded the finding (50 to 160 ms cooperative frames on its demo
stack) and #1411 fixed it and recorded what it measured in §3's
Resumable paragraph. Whichever merged second was to replace the finding
with a pointer; #1411 merged second.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant