fix(geometry): hoist the AABB into point_inside instead of rescanning (#3354) - #3386
fix(geometry): hoist the AABB into point_inside instead of rescanning (#3354)#3386BIMvoice wants to merge 4 commits into
Conversation
…#3354) INCOMPLETE — committed to preserve the work, not because it is ready. `point_inside` in `kernel/arrangement/classify.rs` takes the target box as a parameter instead of calling `tris_aabb(tris)` per query. Callers pass a box they already hold: `BComponents::inside` its cached padded `aabbs[k]`, and `boolean_vids_components` the BVH root box that the build already computed. `union_all` hoists each mesh's box out of the per-probe loop. Passing a SUPERSET box is verdict-identical to a fresh rescan: ray length past the true triangle-containing box crosses zero triangles, so parity is unaffected. That is the argument the change rests on and it is documented at the call sites. WHAT IS NOT DONE, and why this is not a PR: - The equivalence test's non-vacuous half is unfinished. Part (1) checks a superset box gives byte-identical verdicts; part (2) must show a SHRUNK (non-superset) box flips a verdict, or part (1) proves nothing. A first draft tripped `sound_far`'s commensurability debug_assert and was being rebuilt when the machine ran out of disk. - No before/after timing was measured. This is a performance change, so an unmeasured speedup claim would be an assertion, not a result. - The full geometry suite was not run against this state. Three of four adjacent tests passed at the time work stopped, including the 120k-sample analytic oracle differential test, which is the one that would catch a parity break.
…3354) Finishes 2fae5a8, preserved on upstream/wip/3354-point-inside-aabb: hoisting the target AABB into point_inside as a parameter instead of rescanning the mesh on every ray-parity query. Completes the equivalence test's non-vacuous half. Part (1) (a superset box gives a byte-identical verdict to the exact box) already passed, but proved nothing without part (2): a box that does NOT contain the mesh must be able to flip a verdict, or point_inside might not be using its aabb argument at all. The prior draft's grid search for such a case tripped sound_far's commensurability debug_assert and never found one. Replaced the search with a constructed case: place the ray's default far endpoint (before sound_far's extend-to-escape logic runs) strictly inside the exact box but within `shrink` of one face. Against the exact box that endpoint is interior, so sound_far extends it to truly clear the mesh, giving the correct verdict. Against the shrunk box, that same endpoint is already outside on that axis, so sound_far's early-return hands it back unextended — a point strictly inside the real solid, corrupting the parity count for an exterior query point. This also avoids the debug_assert entirely, since the shrunk-box call never reaches the branch it guards. Also verified: all three callers' held boxes (BComponents's padded aabbs[k], the BVH's root_aabb, union_all's hoisted tris_aabb per mesh) are genuine supersets of what tris_aabb(tris) would compute — two are exact, one is padded outward — so no caller relies on a false premise. Not measured: a release-mode timing comparison was attempted but the shared CARGO_TARGET_DIR's release cache was corrupted by a concurrent build (duplicate lang-item errors from two different libcore builds), and disk headroom did not allow a clean rebuild. This is reported as an unmeasured redundant-scan removal, not a measured speedup. Refs #3354
|
Warning Review limit reached
This review includes 4 billable files and costs up to $1.00. Or wait 22 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Comment |
Viewer benchmark⚠ 1 metric(s) exceeded the regression threshold (advisory only, not blocking). 01_Snowdon_Towers_Sample_Structural(1).ifcBaseline recorded 2026-07-01T20:31:05.538Z on github-actions ubuntu-latest, viewer-benchmark-ci (headless Chrome, SwiftShader ANGLE), production build.
AC20-FZK-Haus.ifcBaseline recorded 2026-07-01T20:30:59.972Z on github-actions ubuntu-latest, viewer-benchmark-ci (headless Chrome, SwiftShader ANGLE), production build.
Refresh the baseline from a CI run: dispatch the Benchmark workflow with |
The Rust module-size ratchet (rust/processing/tests/module_size_ratchet.rs) failed: classify.rs is 720 lines on main -- exactly its recorded budget -- and this PR's additions took it to 754. Compressed this PR's own doc comments and compacted `solid_side`'s signature, keeping every claim: the superset-box soundness argument, why the inflated component box is verdict-identical rather than merely faster, and why the BVH root box can be reused. 754 -> 739. That is still 19 over, and the remaining gap cannot be closed without deleting the soundness rationale itself -- which is the one comment that must not go, since it is what justifies passing a box instead of rescanning. Raising the budget is the documented escape hatch, but the ratchet's own notes record a raise reaching main and being undone (#2658), and this is an UNMEASURED optimisation, so that trade is not mine to make unilaterally. Left for the maintainer; see the PR comment.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
6c6a2ae used `git add -A` in a worktree a concurrent agent was writing to, so it committed 267 lines of that agent's in-progress #3353 diagnosis work -- consolidate.rs (+71), classify_tests.rs (+104), arrangement/tests.rs (+92) -- into this PR, which is about hoisting the AABB into point_inside and has nothing to do with any of it. Restored all three: consolidate.rs and tests.rs to upstream/main, and classify_tests.rs to this PR's own previous commit (verified zero diff against it). Only the classify.rs comment trim from 6c6a2ae remains. The swept-in work is not lost -- it is preserved in 6c6a2ae and can be recovered from there. My own rule, broken by me: check `git status` before staging, and never `git add -A` in a shared tree.
|
This PR is red on the Rust module-size ratchet, and I do not think it should be forced green. Your call.
I compressed this PR's own comments and compacted The remaining gap cannot be closed without deleting the soundness rationale — the comment explaining why passing a caller-held box is verdict-identical to rescanning (a superset only lengthens the far endpoint, past where no triangles remain, so parity is unchanged). That is precisely the comment that must not go: it is the argument the whole change rests on, on a file every CSG operation depends on. So the options are:
My honest read is that (3) is defensible and possibly right. This is an unmeasured optimisation — the benchmark could not be run (a shared cargo target dir was corrupted mid-session), and the PR says so plainly rather than implying a speedup. Trading a budget raise on correctness-critical code for an unquantified gain is a poor deal, and I would rather say that than quietly raise the number. What the PR does have going for it, independent of speed: Happy to do (1) or (2) if you prefer either; I did not want to pick unilaterally. Separately: an earlier commit here ( |
|
The geometry reasoning here is sound and I checked it on three legs rather than one, so this is close to ready. The red check is mechanical. Why "Rust tests" is red: it is not a behaviour failure. It is the module-size ratchet at Behaviour preservation confirmed:
What to do: get Please do not raise the budget. And if you regenerate the allowlist, check the diff afterwards, because Thanks for flagging in the changeset that the speedup is unmeasured. That is the right way to write it up. |
|
Do not raise the budget, and do not delete the rationale. Split the file. You are right that the comment is the part that must not go. It is the argument the whole change rests on, and The third option the ratchet's own message points at is the right one here: move the ray-parity block, That is also the honest answer to the ratchet's question. The file is at its budget because it is genuinely doing several jobs; the budget is telling you to separate one out, not to write less about what you did. For the record, I verified the change itself on three legs before deciding this, so the only thing between this PR and merge is the line count:
Thanks for the revert commit dropping the files the earlier commit swept in. That sweep is a real trap in this repo and it caught two other PRs in this same batch: |
Summary
point_insideinrust/geometry/src/kernel/arrangement/classify.rsused to calltris_aabb(tris)— an O(N) scan of every triangle — on every ray-parity query, purely to size the far endpoint. It now takes that box as a parameter instead.BComponents::insideits cached, padding-inflated per-component box;boolean_vids_components's regime-2 probe the BVH's already-computed root box;union_alleach mesh'stris_aabb, hoisted out of its per-probe loop instead of recomputed for every other mesh's boundary triangle.sound_faronly extends the far endpoint to clear whichever box it is handed, and clearing a bigger box means clearing the real one too, past which there are no more triangles to cross. Checked all three call sites' held boxes are genuine supersets oftris_aabb(tris)— two are exact, one is padding-inflated — so this is a redundant-scan removal, not a behavior change.What this finishes
This resumes
2fae5a8bd(preserved onupstream/wip/3354-point-inside-aabb), an earlier attempt that was cut off by a full disk. That commit's message was explicit about what was missing:sound_far's commensurabilitydebug_asserttrying. Replaced with a constructed case: the ray's default far endpoint is placed strictly inside the exact box but within the shrink margin of one face, so the exact box triggerssound_far's extend-to-escape branch (correct verdict) while the shrunk box's early-return hands back an endpoint that is still inside the real solid (corrupted verdict) — and never reaches the debug_assert's branch.CARGO_TARGET_DIRused in this environment had its release cache corrupted by a concurrent build (duplicate lang-item errors from two conflictinglibcorebuilds), and available disk did not allow a clean rebuild to retry. This PR is a redundant-computation removal with an unmeasured effect on wall time, not a measured speedup — flagged explicitly in the changeset.Test plan
cargo test -p ifc-lite-geometry --lib classify_tests— 4/4 pass, including the completed non-vacuous equivalence testcargo test -p ifc-lite-geometry --lib kernel::arrangement— 16/16 passcargo test -p ifc-lite-geometry --lib(full crate unit suite) — 728 passed, 0 failed, 1 ignoredcargo test -p ifc-lite-geometry --test touching_operand(the Multi-opening cuts tear thin shells open, and the kernel removes volume from a merely touching operand #3341 end-to-end regression gate) — 2/2 passRefs #3354
https://claude.ai/code/session_01QPHChk3Ve9N519A4kY7436