Repository navigation
fillContourLeft: up to 2.8x faster on meshes without regular face order; fillContourLeftUpToArea stops at area limit - #7683
Conversation
…ToArea Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grantim
left a comment
There was a problem hiding this comment.
I checked the new traversal against master edge by edge, and on a model of both algorithms with ~12K random contours, including degenerate ones (edges passed both ways, boundary edges without a left face, faces with 2-3 contour edges). I found no input where fillContourLeft returns a different set than before. The comments below are about the stop case of fillContourLeftUpToArea, the contour passes, and tests.
Also: the benchmark tables were measured with std::vector fronts, and the description says MR::Vector costs 5-15% under MSVC, so the 1.15x in the title may be about 1.0-1.1x at the current commit. Could you re-measure the final commit?
…filled contour faces; degenerate-case tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grantim
left a comment
There was a problem hiding this comment.
All points from the previous round are addressed, and I found no input where fillContourLeft returns a different set than master: I checked edge by edge, and on a model of both algorithms that now also matches master's fill order. Two notes on the description, not blocking:
- The second table gives the UV sphere's
fillContourLeftas 26.1 ms, while the main table has 23.1 ms for the same case and compiler; 26.1 looks like the ico sphere's value. - The 0.90x clang-cl row (UV sphere,
z > -0.99) isn't explained by the code:z > 0on the same mesh does the same work per face and gives 1.03x, and the 23.1 / 26.1 difference suggests the spread is of the same size. A regular grid mesh (like those from distance maps) would show whether meshes already in fill order really get slower.
…efetched, unfill uncounted faces on stop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks! Both notes on the description:
A regular grid, as you suggested:
So the grid gets about 2.2x faster, not slower. A front crossing the grid's rows touches a new row per edge, so this order isn't fill order for the hardware prefetcher, unlike the UV sphere's rings. 🤖 Addressed by Claude Code |
fillContourLeftis faster on meshes without a regular face order:AABBTreeconstruction);EdgeHashSetinstead ofParallelHashSet, and the result is returned by value instead of being copied.fillContourLeftUpToArea( mesh, contours, maxArea )stops filling as soon as the area of the filled faces exceedsmaxArea, and returnsContourLeftFill{ region, area, exceeded }. Faces are counted when they leave the front, where their half-edge records are already prefetched; on a stop the faces not counted yet are unfilled, soareais always the area ofregion. The same template does both fills, so the existing function gets no extra work.MRMesh.FillContourLeft. It covers caps, bands, a scattered region (faces with 2-3 contour edges, faces touching by a vertex), a path followed by its reverse, andmaxArea = 0.Benchmark
Each case fills the left side of the boundary of the faces with center
z > thresholdon a unit sphere. All results matched that region exactly.fillContourLeftmeasured at e47d90d against its master base (at 7a17734 it measures the same within noise), on Windows, single-threaded. Times are the minimum over 6 interleaved runs of each DLL, 10 repetitions each. clang-cl is what the Windows distributions are built with; the MSVC columns are for reference.z >makeUVSphere( 1, 2000, 2000 )makeSphere( 2M verts )packOptimally()* Noise, not a slowdown: this case moves by ±15% from process to process (its topology alone is about 384 MB, so memory placement differs per run). Over 12 interleaved processes of each, with both loops copied into one clang-cl benchmark, master took 44.0 / 50.7 / 56.7 ms (min / avg / max) and this PR 40.7 / 51.6 / 62.1 ms. The UV sphere's faces are already in fill order, so the hardware prefetcher leaves little for the software prefetch to add.
fillContourLeftUpToAreawith clang-cl on the same cases, at 7a17734. Without stopping it takes 2.1-2.5x the time offillContourLeft, which is the cost of computing the area of every triangle; withmaxAreaset to half of the region's area it stops halfway:z >fillContourLeft, msUpToAreano stop, msUpToAreahalf of the area, ms🤖 Generated with Claude Code