Unit 1: Micro-optimizations (stack alloc + So3Y const ref)#15
Open
adthoms wants to merge 1 commit into
Open
Conversation
…ccess Replace heap-allocated subset_indices arrays (new/delete) with stack arrays in all graph construction methods, eliminating per-iteration heap allocations in hot loops. Remove unused edge_pair_indices allocations from BuildCompGraphSerial and BuildCompGraph parallel. Add So3Y::ref() method returning const Eigen::Matrix3d& for zero-copy access by callers using So3Y* directly (e.g. SraCompCheck). The base class operator[] continues to return by value since matrix-backed types return Eigen temporaries. Co-Authored-By: Claude Opus 4.6 (1M context) <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
subset_indicesin all 9 graph construction methods incore.hpp, replacingnew size_t[]/delete[]with stack arrays to eliminate per-iteration heap allocations in hot loopsedge_pair_indicesheap allocations fromBuildCompGraphSerialandBuildCompGraph(parallel)So3Y::ref()method returningconst Eigen::Matrix3d&for zero-copy access; updateSraCompCheckto use it instead of the by-valueoperator[]SetBase::operator[]explaining the by-value return design for Eigen-backed typesTest plan
tests/problems_test.cpp: New test verifiesSo3Y::ref()returns a stable const reference (same address on repeated calls) andoperator[]still works by valuetests/core_test.cpp: New test exercises serial, parallel_edge_buffer, and parallel_vertex graph construction methods and confirms they produce identical edge sets after the stack-allocation change🤖 Generated with Claude Code