Skip to content

TriWild: tracked winding number per region, input winding numbers only when needed; jse and polysolve with cheaper validation and solves - #1193

Merged
danielepanozzo merged 6 commits into
mainfrom
perf/triwild-overheads
Nov 17, 2026
Merged

danielepanozzo merged 6 commits into
mainfrom
perf/triwild-overheads

Conversation

@danielepanozzo

@danielepanozzo danielepanozzo commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Four changes that make small TriWild runs cheaper: two in TriWild, and two dependency pins. Three of them leave every output byte-identical. The fourth stops writing output fields nobody asked for, the wn_* fields under filters "tracked" and "flood", unless skip_winding_number is false.

Where the time went

Sampled on a batch of small 2D inputs meshed through the memory route with filter: "tracked" and the default num_threads: 0: 69 TriWild calls of a few hundred to a few thousand triangles, 49k triangles in all, 25.2 s. The batch uses #1188's options, so it was measured with #1188 applied, before and after.

time
split, collapse, swap 9.4 s the mesh operations
tracked winding number (filter: "tracked") 3.1 s an atan2 per face and curve edge
polysolve Solver::create 2.5 s 40 ms per mesh, 99% of it jse validating the parameters
jse validating each call's own parameters 1.1 s
input winding numbers (the wn_* fields) 1.0 s computed under "tracked" although only filter "input" reads them
polysolve's own work in minimize() 0.9 s

Changes

  1. TriWild: the tracked winding number once per region (TriWildMesh::compute_tracked_winding_number). When the oriented tracked curves are closed, their winding number is constant on each connected set of faces that no curve edge separates. It is evaluated once per such region, at its first face's centroid, instead of at every face. Curves that are not closed are still evaluated face by face. Only the inside test reads the value, which is not written out.

  2. jse pinned at main with Index the rules by pointer instead of copying them for every node (~150x faster validation) geometryprocessing/json-spec-engine#9 (merged). Validation no longer copies the specification for every node of the input, about 170× faster with byte-identical results. A polysolve solver is now created in 0.5 ms instead of 43 ms, and each component call validates its parameters in well under a millisecond.

  3. polysolve pinned at main with Cheap repeated Solver::create, and a lighter minimize() for small problems (results unchanged) polyfem/polysolve#131 (merged). Creating a solver again with the same parameters skips their validation (0.02 ms). minimize() allocates and times less: 0.74 µs instead of 1.02 µs for a 2-unknown Newton solve, with the same iterates.

  4. TriWild: skip_winding_number also skips the input winding numbers under filters "tracked" and "flood". Neither filter reads them; until now they were skipped only under "none". They are still computed for filter "input", which keeps the faces by them, and whenever skip_winding_number is false. The default is true, so with "tracked" or "flood" the wn_* fields are now written only on request. The tutorial already described this behaviour ("leaves them out when no filter needs them"); the spec's doc and test_component_io now say so too.

The same batch takes 15.6 s instead of 24.9 s: about 3.3 s from (1), 4.4 s from (2), 0.4 s from (3) and 1.5 s from (4).

Identical outputs

Every output below was compared byte for byte; reports were compared without their timings.

  • Integration manifest (integration_tests.json), before and after:
    • all outputs are identical for the 51 configs that run on main;
    • tetwild_crown and tetwild_octocat were run with num_threads: 0, because with 10 threads they differ from run to run on main itself;
    • the four simwild_tight_seal_geom_* configs fail on main as well: they use an option main does not have yet.
  • The 16 challenging_triwild_* configs and the 4 triwild_* ones, run with filter: "tracked", plus triwild_collection with filter_inputs: all outputs identical (.msh, .vtu, envelope, surface, report). With (4) this holds when skip_winding_number is false; with the default the only difference is the missing wn_* fields.
  • The batch above: identical meshes.
  • Unit tests: ctest 296/296, with the pins at the merge commits and main (tight_seal_geom: clean up comments #1187) merged in. The jse and polysolve PRs carry their own identity harnesses: 1,492 inputs and 8,767 solves.

Not done

  • The input winding numbers, when they are computed, are still evaluated face by face: their values are written out, so evaluating them per region would change those values by round-off.
  • One solver per thread instead of per mesh. Not needed once creation is cheap. It would also take the per-mesh m_solver slot away from topological offset, which sets its own stopping criteria on it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF

danielepanozzo and others added 6 commits November 17, 2026 15:40
filter "tracked" evaluated the winding number of the tracked curves at
every face's centroid, an atan2 summed over every curve edge: faces
times edges, and on 2D inputs of a few thousand triangles with a few
hundred curve edges, about a fifth of the run. For closed curves the
winding number is constant on each connected set of faces that no curve
edge separates, so it is now evaluated once per such region, at the
centroid of its first face, and given to all its faces. Curves that are
not closed, whose winding number varies off them, are still evaluated
face by face.

Only the inside test reads the value (it is not written out), so the
same faces are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
jse validated a JSON against its specification by copying, for every node
of the input, every rule of the specification. Each component call
validates its parameters, and every polysolve solver created for the
vertex smoothing -- one per mesh -- validates its own four times (the
nonlinear parameters, and the linear ones for each of DenseNewton's
three strategies): 40 ms per solver, the time of a whole TriWild run on a
small input. With json-spec-engine#9 a polysolve solver is created in
0.5 ms, and the validated and defaulted JSON is byte-identical.

Pinned at the PR's head; move to its merge commit once merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
The vertex smoothing creates one polysolve solver per mesh, and creating
one validated its parameters with jse every time: with polysolve#131 a
solver created again with the same parameters skips the validation
(0.02 ms instead of 41 ms; the first one still validates), and
minimize() allocates and times less (0.74 instead of 1.02 us for a
two-unknown Newton solve). The iterates are the same.

Pinned at the PR's head; move to its merge commit once merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
json-spec-engine#9 and polysolve#131 are merged; the merge commits have
the same trees as the heads pinned before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
…lters "tracked" and "flood"

The per-input winding numbers (the wn_<i> fields) were skipped only under
filter "none". Filters "tracked" and "flood" do not read them either: they
were computed, an atan2 per face and input segment, for output fields
nobody asked for, about a tenth of a run on small 2D inputs. They are now
computed for filter "input", which keeps the faces by them, and with
skip_winding_number false, as the tutorial already says ("leaves them out
when no filter needs them"). skip_winding_number is true by default, so
filters "tracked" and "flood" no longer write the wn_ fields unless it is
set to false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
@danielepanozzo danielepanozzo changed the title TriWild: tracked winding number per region; jse and polysolve with cheaper validation and solves TriWild: tracked winding number per region, input winding numbers only when needed; jse and polysolve with cheaper validation and solves Nov 17, 2026
@danielepanozzo
danielepanozzo merged commit d7cbddf into main Nov 17, 2026
13 checks passed
@danielepanozzo
danielepanozzo deleted the perf/triwild-overheads branch November 17, 2026 22:38
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