Skip to content

perf(check): settle a B-spline face's volume at its partials' noise, and match its sides through their knots' rounding - #2944

Merged
andymai merged 5 commits into
andymai:mainfrom
Robokan:perf/check-volume-noise-floor
Nov 30, 2026
Merged

andymai merged 5 commits into
andymai:mainfrom
Robokan:perf/check-volume-noise-floor

Conversation

@Robokan

@Robokan Robokan commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What

Measuring the volume of a degree-5 B-spline wall whose 48-pole profile ends in a knot span about 4000 times narrower than its domain took seconds. There were two causes, and the fix for the first needed a third change. All three are in crates/check/src/properties/boundary.rs.

  1. The adaptive quadrature never settled. It asked for 1e-12 of the integral. In that narrow span, the de Boor partials carry rounding noise of about 1e-11, so it halved to its depth limit. A halving can also stop when it shrinks the gap by less than eight times, with the gap already within 1e-9 of the integral. The code then measures the noise from samples at neighbouring floating-point numbers. It stops only when each term's gap is within twice the interval's width times that noise. The width counts as a positive size, so a reversed boundary piece settles too.

  2. The face's edges weren't read as its surface's sides. The whole-domain path needs them to be. Their knots had to match the surface's exactly forward, or to within 4 ulps of the span reversed. A file's edges differ from the surface's knots by the domain's rounding: one mirrored, one in the last digit. So the face fell to the slower integral that projects every boundary point. Knot spans now match either way within that rounding, as long as the difference also stays within 1e-9 of the span.

  3. A sample budget. With the noise rule, integrals settle. Before, an integral that never settled ran to its depth and returned None. The face then went at once to the other way of measuring it. On one imported part, the wall's integrals settle only at their noise. A boundary integral then asked for settled integrals without end. Its volume ran for minutes, and the other way takes 0.4 s.

    Each face's integral now has a budget of samples, shared by its nested integrals. The budget is a million, or 16 times the first pass if that is more. Past it, the integral returns None, as at the depth limit. Most faces take a few tens of thousands; a rational patch weighted both ways takes a few hundred thousand.

The author measured an earlier version on two such parts from a real design. On a loaded machine, they took 0.017 s and 0.13 s, down from 10 s and 78 s. The volumes stayed the same.

Tests

Unit tests in the module's tests and one integration test cover the changes:

  • a_noisy_integrand_settles_at_its_noise: an integrand with 1e-11 relative noise settles within 1e-9 of its integral in fewer than 1000 samples, in both directions.
  • a_side_matches_through_its_knots_rounding: a degree 1 x 5 wall with narrow end spans. A mirrored reversed edge and a forward edge nudged in its last digit both match. A knot moved by 1e-7 does not.
  • a_smooth_wiggle_is_not_taken_for_noise: a smooth integrand with a small wiggle still settles to 1e-14, in both directions.
  • a_patch_of_many_knot_spans_is_read_over_its_domain: a 70 x 70 bicubic patch gets a result, where a fixed budget of a million samples failed it.
  • crates/io/tests/spline_wall_volume_settles.rs: the imported part's volume comes back within 60 s, to 1e-6 of its value before the noise rule. It times out without the budget.

On this branch merged with #2942 and main at edf1a9d50, the check (203), operations (2839) and io (651) tests passed.

🤖 Generated with Claude Code

…and match its sides through their knots' rounding

A degree-5 wall whose 48-pole curve ends in a knot span about 4000 times
narrower than its domain took seconds to measure, for two reasons.

The adaptive quadrature asked for 1e-12 of the integral, but in that span
the de Boor partials carry rounding noise of about 1e-11, so the halving
never settled and ran to its depth limit. It now stops once a halving
shrinks the gap by less than eight times, provided the gap is already
within 1e-9 of the integral: past that the gap is the samples' noise.

The whole-domain path needs the face's edges to be its surface's sides,
and their knots had to match exactly forward or to 4 ulps of the span
reversed. A file's edges differ from the surface's knots by the domain's
rounding (one mirrored, one in the last digit), so the face fell to the
slower integral that projects every boundary point. Knot spans now match
either way within that rounding, so long as it also stays within 1e-9 of
the span.

On two such parts the volume takes 0.017 s and 0.13 s, from 10 s and 78 s (on a loaded machine),
unchanged to the digits shown (38.8308, 1885.7562).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 23:37
@greptile-apps

greptile-apps Bot commented Nov 27, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…udget

With the noise floor, each of a face's integrals settles, where before
one that never settled ran to its depth and returned None, and the face
went at once to the other way of measuring it. On one imported part
whose B-spline wall's integrals settle only at their noise, a boundary
integral then asked for them without end: its volume ran for minutes,
where the other way takes 0.4 s.

Each face's integral now takes at most a million samples of its
integrand, shared by its nested integrals, and returns None past that,
as at the depth limit. Most faces take a few tens of thousands; a
rational patch weighted both ways takes a few hundred thousand. The two
slow walls the floor was for still measure in 0.017 s and 0.13 s.

Test `spline_wall_volume_settles.rs`: that part's volume comes back
within 60 s (0.4 s), to 1e-6 of what it was before the floor. It times
out without the budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The gap-ratio criterion can mistake truncation error for sample noise and return an inaccurate integral, requiring an independently justified noise bound and a noise-free regression test.

1 open issue

Review effort: Balanced

Comment thread crates/check/src/properties/boundary.rs Resolved
Both sides added tests at the end of the properties boundary module: main the
wall closed along u read over its domain, this branch the noisy integrand and
the side matched through its knots' rounding. Both are kept.
… a face's sample budget

A halving that shrinks the gap less than eightfold now keeps its halves
only when each term's gap is within twice the interval's width times the
noise read off the integrand. The noise is the second difference of the
samples at the floating-point numbers either side of the interval's
middle. A smooth wiggle on a large mean no longer settles 1.5e-9 off its
integral; a noisy integrand still settles at its noise.

A face's sample budget is now sixteen times the samples of its first
pass, where that is more than a million. A bicubic patch of 70 by 70
control points takes a million samples on its first pass, and the fixed
budget refused it.

The noisy test uses Madd::madd, as library code must.

Tests: a smooth wiggle settles to 1e-14 of its integral, and a 70 by 70
bicubic patch reads over its domain. Both fail without the change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The noise bound becomes negative for reversed boundary pieces, preventing noise settling and potentially exhausting the depth or sample budget; it needs an absolute interval width and regression coverage in both directions.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread crates/check/src/properties/boundary.rs Resolved
A boundary's pieces may run from a larger parameter back to a smaller
one. The noise bound took the interval's signed width, which is negative
there, so such a piece never settled at its noise and halved to its depth.

Test: the noisy integrand settles at its noise read either way along its
interval, and the smooth wiggle settles to 1e-14 either way. The reversed
noisy case fails without the change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The convergence and geometric-tolerance changes across eight nested integrals require specialist numerical review and independent native/WASM accuracy validation on rational and trimmed faces, beyond the available static evidence and author-reported tests.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@andymai
andymai merged commit 276b9df into andymai:main Nov 30, 2026
23 of 24 checks passed
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.

3 participants