ENH: OoC optimizations for CCL/Segmentation filters#1557
Closed
joeykleingers wants to merge 3 commits intoBlueQuartzSoftware:developfrom
Closed
ENH: OoC optimizations for CCL/Segmentation filters#1557joeykleingers wants to merge 3 commits intoBlueQuartzSoftware:developfrom
joeykleingers wants to merge 3 commits intoBlueQuartzSoftware:developfrom
Conversation
Add reusable AlgorithmDispatch.hpp utility with IsOutOfCore(), AnyOutOfCore(), ForceOocAlgorithm(), ForceOocAlgorithmGuard, and DispatchAlgorithm<InCore, OOC>() so filters can dispatch to separate in-core and out-of-core algorithm implementations at runtime. Includes documentation in docs/AlgorithmDispatch.md. No filters are using this infrastructure yet — it is provided as reusable scaffolding for future OOC optimization work.
Consolidate OOC filter optimizations from identify-sample-optimizations worktree: - Add AlgorithmDispatch.hpp and UnionFind.hpp utilities - SegmentFeatures: Add executeCCL() with 2-slice rolling buffer + Union-Find - ScalarSegmentFeatures: CCL dispatch + CompareFunctor::compare() - EBSDSegmentFeatures: CCL dispatch + isValidVoxel/areNeighborsSimilar - CAxisSegmentFeatures: CCL dispatch + isValidVoxel/areNeighborsSimilar - Tests: PreferencesSentinel, ForceOocAlgorithmGuard, 200^3 benchmarks
Update IdentifySample and FillBadData to use the AlgorithmDispatch BFS/CCL split pattern instead of monolithic inlined algorithms. Add BFS/CCL split files, update tests with ForceOocAlgorithmGuard, PreferencesSentinel, and 200x200x200 benchmark test cases.
Contributor
Author
|
Reopening this under a different PR. |
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.
Summary
Optimize 5 CCL/Segmentation filters for out-of-core performance using BFS/CCL algorithm dispatch:
executeCCL()to shared SegmentFeatures base with 2-slice rolling buffer + union-findisValidVoxel/areNeighborsSimilaroverridesisValidVoxel/areNeighborsSimilaroverridesAll filters use
DispatchAlgorithmfrom #1545 to select the optimal path at runtime. Tests updated withForceOocAlgorithmGuard+GENERATE(false, true)to exercise both algorithm paths, plus 200x200x200 benchmark test cases.Algorithm Details
Original Algorithm: DFS Flood-Fill
All five filters used a depth-first search (DFS) flood-fill to find connected components:
determineGrouping()Why it's slow OOC: Each stack pop accesses an arbitrary voxel, then reads 6 scattered neighbors. With chunked storage, each jump may evict the current chunk and load a new one from disk, causing 50x-621x slowdown.
Optimized Algorithm: Chunk-Sequential CCL with Union-Find
A two-phase scanline algorithm that processes the grid in strict Z-Y-X order, never accessing data out of sequence.
Phase 1 — Forward Labeling with Rolling Buffer
Phase 2 — Resolution and Relabeling
Dispatch Strategy
Each filter checks
IsOutOfCore(*featureIdsArray) || ForceOocAlgorithm():executeCCL()(chunk-sequential CCL)execute()(original DFS flood-fill)Per-Filter Notes
isValidVoxel()areNeighborsSimilar()CompareFunctor::compare()(11 data types)LaueOpsTradeoffs
Performance (200x200x200 programmatic datasets)
Per-Filter Results
IdentifySample — BFS (in-core) / scanline CCL with union-find (OOC)
ScalarSegmentFeatures — base
executeCCL()with type-dispatched comparatorEBSDSegmentFeatures — base
executeCCL()with quaternion misorientationCAxisSegmentFeatures — base
executeCCL()with c-axis angleFillBadData — BFS (in-core) / 4-phase CCL with on-disk deferred fill (OOC)
FillBadData's OOC baseline was already fast (6s), so the optimization is primarily RAM reduction (O(N) → O(slice)) rather than speed.
Group Summary
Test Plan
ForceOocAlgorithmGuard+GENERATE(false, true)