Repository navigation
perf(check): settle a B-spline face's volume at its partials' noise, and match its sides through their knots' rounding - #2944
Merged
Conversation
…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>
|
PR author is not in the allowed authors list. |
…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>
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.
There was a problem hiding this comment.
🟡 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
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.
There was a problem hiding this comment.
🔵 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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.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.
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.
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
testsand 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
mainatedf1a9d50, the check (203), operations (2839) and io (651) tests passed.🤖 Generated with Claude Code