ENH: SurfaceNets memory optimization via SoA layout#1546
Open
imikejackson wants to merge 1 commit intoBlueQuartzSoftware:developfrom
Open
ENH: SurfaceNets memory optimization via SoA layout#1546imikejackson wants to merge 1 commit intoBlueQuartzSoftware:developfrom
imikejackson wants to merge 1 commit intoBlueQuartzSoftware:developfrom
Conversation
…mprovements Reduce SurfaceNets cell map memory usage by ~25% and eliminate redundant O(N^3) traversals while producing identical output. Key changes: - Replace struct Cell (16 bytes/cell with padding) with separate flag and vertex index arrays (12 bytes/cell) - Replace Vertex::cellIndex[3] (12 bytes) with flat index (8 bytes) - Merge init() and setCellVertices() into a single pass - Optimize interior cell label lookups with precomputed corner offsets - Cache edge crossing count during cell setup - Use local vertex buffer during relaxation for better cache locality - Remove dead code: MMGeometryOBJ, MMGeometryGL, unused methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Cellstruct array (16 bytes/cell) with Structure-of-Arrays layout (12 bytes/cell), saving ~25% cell map memoryVertex::cellIndex[3](12 bytes) with flat index (8 bytes), saving ~33% vertex array memoryTest plan
Performance Comparison NO SMOOTHING
561 x 381 x 528 3D EBSD Stack
Before: 9.46 GB used and 1:14 filter time
After: 9.20 GB used and 1.06 filter time
Smoothing
Aftger takes 12.80 GB (as reported by DREAM3D-NX itself)
This may not really be worth it. The best we could do is have a templated version based on the total number of voxels. If the total is < UINT32_MAX then we could shave down the memory buy a large margin. The issue is the 64 bit clean implementation needs Size_t indices stored which just takes a bunch of memory.
Anyone have any thoughts?