Skip to content

Unit 1: Micro-optimizations (stack alloc + So3Y const ref)#15

Open
adthoms wants to merge 1 commit into
MIT-SPARK:masterfrom
adthoms:worktree-agent-a2804811
Open

Unit 1: Micro-optimizations (stack alloc + So3Y const ref)#15
adthoms wants to merge 1 commit into
MIT-SPARK:masterfrom
adthoms:worktree-agent-a2804811

Conversation

@adthoms
Copy link
Copy Markdown

@adthoms adthoms commented Apr 15, 2026

Summary

  • Stack-allocate subset_indices in all 9 graph construction methods in core.hpp, replacing new size_t[]/delete[] with stack arrays to eliminate per-iteration heap allocations in hot loops
  • Remove unused edge_pair_indices heap allocations from BuildCompGraphSerial and BuildCompGraph (parallel)
  • Add So3Y::ref() method returning const Eigen::Matrix3d& for zero-copy access; update SraCompCheck to use it instead of the by-value operator[]
  • Add documentation comment to SetBase::operator[] explaining the by-value return design for Eigen-backed types

Test plan

  • tests/problems_test.cpp: New test verifies So3Y::ref() returns a stable const reference (same address on repeated calls) and operator[] still works by value
  • tests/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

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant