You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(geom): lazily index face triangles and memoize smooth_seam in tangent_chain - #27083
Eliminates O(L * T) full-mesh triangle scans in Mesh::tangent_chain / smooth_seam by building a lazy per-face triangle index (FaceTriIndex) only on the first unflagged edge fallback and memoizing per-edge results in seam_cache. Preserves bit-identical ascending triangle order and adds zero overhead when sharp_edges / smooth_edges decide directly.
No actionable comments were generated in the recent review.
Walkthrough
tangent_chain now lazily indexes triangles by face and caches seam results for candidate edges. Regression tests compare indexed traversal with a reference scan across varied mesh cases. An ignored benchmark exercises a larger chain and seam-branch configuration.
Changes: Tangent chain seam lookup
Layer / File(s)
Summary
Indexed seam lookup crates/geom/src/mesh.rs
FaceTriIndex groups triangle IDs by face and supports dense or sparse storage. smooth_seam uses the index when provided and retains the scan path when no index is supplied.
Chain caching and regression coverage crates/geom/src/mesh.rs, crates/geom/src/tests.rs
tangent_chain shares a lazy index and caches candidate-edge seam results. Tests compare traversal with a reference implementation and add an ignored scaling benchmark.
This change speeds up tangent-chain seam lookups by indexing triangles per face and caching per-edge results, and it keeps the previous behavior. No concrete merge-blocking risk was found.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title names the main change: lazy per-face triangle indexing and memoized smooth_seam in tangent_chain. It matches the raw summary (FaceTriIndex, seam cache) and the objectives (issue #27082). It …
Description check
The description follows the template's main sections (Change, Validation) and gives a clear technical summary, a benchmark table, and verification results. It links issue #27082 and includes the requi…
Linked Issues check
[#27082] The issue asks to remove the O(L * T) full-mesh triangle scans in the tangent_chainsmooth_seam fallback on G1/unflagged edges. The whole-PR diff of crates/geom/src/mesh.rs (merge base …
Out of Scope Changes check
All changes in the whole-PR diff relate to the linked issue. The mesh.rs changes add the lazy index, the seam cache, the indexed lookup path, and the None argument at the tangent_join call site.…
Existing Defaults Unchanged
The check fails only if the PR changes a UX default (default setting or preference, usual command or tool behavior, UI default layout or behavior, or shortcuts). Kernel or geometry results are exclude…
Full details: Title check
Explanation
The title names the main change: lazy per-face triangle indexing and memoized smooth_seam in tangent_chain. It matches the raw summary (FaceTriIndex, seam cache) and the objectives (issue #27082). It uses the perf(geom) prefix and is 80 characters, which fits the concise title standard.
Full details: Description check
Explanation
The description follows the template's main sections (Change, Validation) and gives a clear technical summary, a benchmark table, and verification results. It links issue #27082 and includes the required 'Changes a default: no' line. It does not include the template's 'Test change' line, but the PR does not change existing test expectations, so that line is not needed. The Screenshots section is missing. The Integration status section is also missing. Screenshots are not required for this kernel-level performance change with no observable UI behavior. The Change section does not explain the feature in plain words for a newcomer, and it does not describe the user-visible effect. The description is mostly complete, so the check passes.
Full details: Linked Issues check
Explanation
[#27082] The issue asks to remove the O(L * T) full-mesh triangle scans in the tangent_chainsmooth_seam fallback on G1/unflagged edges. The whole-PR diff of crates/geom/src/mesh.rs (merge base 46ce128 to head 34f5de2) implements this. (1) FaceTriIndex is added. It maps each face to its triangle IDs in ascending order, using a dense offset layout or a sparse HashMap fallback. (2) tangent_chain creates face_tris: Option<FaceTriIndex> as None and passes Some(&mut face_tris) to smooth_seam. The index is built only on the first fallback, through get_or_insert_with. (3) seam_cache: Vec<Option<bool>> memoizes each candidate edge's smooth_seam result within the chain walk. (4) normal_near uses the index when present and keeps the original linear scan when absent, so tangent_join keeps its prior behavior. Sharp and smooth flags still decide before the fallback, so no index is built for those edges. The tests in crates/geom/src/tests.rs add a reference-comparison regression test and an ignored scaling benchmark. The benchmark reports 1334.504 ms before and 24.408 ms after. This evidence is from the PR summary and the diff. I did not rerun the benchmark or tests.
Full details: Out of Scope Changes check
Explanation
All changes in the whole-PR diff relate to the linked issue. The mesh.rs changes add the lazy index, the seam cache, the indexed lookup path, and the None argument at the tangent_join call site. The tests.rs changes add a regression test for tangent_chain and a scaling benchmark for the same path. The PR description states that the change is not a default change. No unrelated refactoring or feature change appears in the reviewed evidence.
Full details: Existing Defaults Unchanged
Explanation
The check fails only if the PR changes a UX default (default setting or preference, usual command or tool behavior, UI default layout or behavior, or shortcuts). Kernel or geometry results are excluded. Evidence from the reviewed range (refs/coderabbit/pre-merge-check/base to head): - Changed files: crates/geom/src/mesh.rs (modified) and crates/geom/src/tests.rs (modified). No other files changed. - mesh.rs changes are internal performance work. tangent_join and tangent_chain pass a new optional FaceTriIndex argument to smooth_seam. tangent_chain adds a per-edge seam_cache so each candidate edge is evaluated once. The new FaceTriIndex keeps ascending triangle order, and callers without an index keep the original linear-scan path. - No settings, preferences, UI, shortcuts, or command-line defaults appear in the diff. The public API signatures are not changed. - The PR description states Changes a default: no, which matches the diff. The change affects only geometry computation speed. The stated behavior is unchanged (bit-identical ordering). Even if results were affected, the check excludes kernel or geometry results from "changed default". No UX default is changed, so the check passes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 2ff98ab and 34f5de2.
Files selected for processing: 2
crates/geom/src/mesh.rs
crates/geom/src/tests.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
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
approved-for-ciReviewed: run the full PR CI (build, tests, goldens, Clippy)area:kernelB-rep kernel, booleans, blends, STEP/IGES
1 participant
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.
Change
Eliminates
O(L * T)full-mesh triangle scans inMesh::tangent_chain/smooth_seamby building a lazy per-face triangle index (FaceTriIndex) only on the first unflagged edge fallback and memoizing per-edge results inseam_cache. Preserves bit-identical ascending triangle order and adds zero overhead whensharp_edges/smooth_edgesdecide directly.Closes #27082
Changes a default: no
Benchmark (
--release)bench_tangent_chain_g1_unflagged_scaling(F=500,T=50,000,L=300, 10 iters, checksum3000):1334.504 ms24.408 ms54.67xfaster (-98.2%)Verification
tangent_chain_(2/2passed)clippy -p solidcraft-geom --lib --tests -- -D warningscleanSummary by CodeRabbit