Skip to content

Make accessors return by value, remove temporary copies (heaptrack profiling)

Fix some temporary allocation hotspots identified by [heaptrack](https://github.com/KDE/heaptrack)

In these cases vectors already existed, but were then having their values copied into new vectors because of not passing by reference. Appears in the top 10 temporary allocations in a trigger job

12015529 temporary allocations of 12576238 allocations in total (95.54%) from
std::_Vector_base<>::_Vector_base(unsigned long, std::allocator<> const&)
  at /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/include/c++/8.3.0/ext/new_allocator.h:111
  in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2021-04-29T2101/Athena/22.0.33/InstallArea/x86_64-centos7-gcc8-opt/lib/libPixelConditionsData.so
std::vector<>::vector(std::vector<> const&)
  at /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/include/c++/8.3.0/bits/stl_vector.h:460
PixelCalib::PixelClusterOnTrackErrorData::getEtaBins() const
  at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelClusterOnTrackErrorData.h:49
PixelCalib::PixelOfflineCalibData::GetConstants() const
  at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetConditions/PixelConditionsData/src/PixelOfflineCalibData.cxx:27
3780600 temporary allocations of 3780606 allocations in total (100.00%) from:
    PixelChargeCalibCondData::getCharge(int, int, int, float) const
      at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetConditions/PixelConditionsData/src/PixelChargeCalibCondData.cxx:336
      in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2021-04-29T2101/Athena/22.0.33/InstallArea/x86_64-centos7-gcc8-opt/lib/libPixelConditionsData.so
    InDet::ClusterMakerTool::pixelCluster(Identifier const&, Eigen::Matrix<> const&, std::vector<> const&, int, std::vector<> const&, InDet::SiWidth const&, InDetDD::SiDetectorElement const*, bool, int, P
      at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetRecTools/SiClusterizationTool/src/ClusterMakerTool.cxx:305
      in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2021-04-29T2101/Athena/22.0.33/InstallArea/x86_64-centos7-gcc8-opt/lib/libSiClusterizationToolLib.so
    InDet::MergedPixelsTool::makeCluster(std::vector<> const&, std::vector<> const&, std::vector<> const&, InDetDD::SiDetectorElement const*, PixelID const&, int&, bool, double, double) const
      at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetRecTools/SiClusterizationTool/src/MergedPixelsTool.cxx:257
      in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2021-04-29T2101/Athena/22.0.33/InstallArea/x86_64-centos7-gcc8-opt/lib/libSiClusterizationToolLib.so
    InDet::MergedPixelsTool::clusterize(InDetRawDataCollection<> const&, PixelID const&) const
      at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetRecTools/SiClusterizationTool/src/MergedPixelsTool.cxx:486
      in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2021-04-29T2101/Athena/22.0.33/InstallArea/x86_64-centos7-gcc8-opt/lib/libSiClusterizationToolLib.so
    InDet::PixelClusterization::execute(EventContext const&) const
      at /build/atnight/localbuilds/nightlies/Athena/master/athena/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/PixelClusterization.cxx:180
      in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_Athena_x86_64-centos7-gcc8-opt/2021-04-29T2101/Athena/22.0.33/InstallArea/x86_64-centos7-gcc8-opt/lib/libInDetPrepRawDataFormation.so
    Gaudi::Algorithm::sysExecute(EventContext const&)

cc @amete, @rbielski

I haven't tried to profile the impact on timing, but the fix is simple and correct in general.

Merge request reports