Skip to content

Use statically allocated 3x3 matrix

Amg::MatrixX cov(3,3) declares a matrix by dynamic allocation (i.e. new) but for matrices below 16 these should be declared on the stack (faster).

Fixes a reported temporary allocation from a heaptrack run:

91387 temporary allocations of 274161 allocations in total (33.33%) from
Eigen::internal::aligned_malloc(unsigned long)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/util
/Memory.h:159
  in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc11-opt/2023-01-24T2101/Athena/23.0.15/InstallArea/x86_64-centos7-gcc11-opt/lib/libTrkSpacePoint.so
void* Eigen::internal::conditional_aligned_malloc<>(unsigned long)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/util
/Memory.h:214
double* Eigen::internal::conditional_aligned_new_auto<>(unsigned long)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/util/Memory.h:374
Eigen::DenseStorage<>::resize(long, long, long)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/DenseStorage.h:408
Eigen::PlainObjectBase<>::resize(long, long)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/PlainObjectBase.h:293
void Eigen::PlainObjectBase<>::_init2<>(long, long, Eigen::internal::enable_if<>::type*)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/PlainObjectBase.h:743
Eigen::Matrix<>::Matrix<>(int const&, int const&)
  at /cvmfs/sft.cern.ch/lcg/releases/eigen/3.3.7-642a5/x86_64-centos7-gcc11-opt/include/eigen3/Eigen/src/Core/Matrix.h:302 
Trk::SpacePoint::setupGlobalFromLocalCovariance()
  at /build/atnight/localbuilds/nightlies/Athena/master/athena/Tracking/TrkEvent/TrkSpacePoint/src/SpacePoint.cxx:61

Probably worth trying to find more instances of this kind of thing, either by grep or by heaptrack.

Merge request reports

Loading