Commit a324ed25 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'mem.AthAllocators-20211021' into 'master'

AthAllocators, etc: Reduce memory requirements.

See merge request atlas/athena!47458
parents 9120668a e91fb971
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ATHALLOCATORS_DATAPOOL_H
......@@ -159,7 +159,7 @@ public:
const static typename alloc_t::Params s_params;
/// minimum number of elements in pool
static const unsigned int s_minRefCount = 1024;
static constexpr size_t s_minRefCount = 1024;
};
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
//-----------------------------------------------------------
......@@ -22,7 +22,7 @@ DataPool<VALUE>::DataPool(size_type n /*= 0*/)
: m_handle (&s_params)
{
if (n > 0)
m_handle.reserve (n);
m_handle.reserve (std::max (n, s_minRefCount));
}
template <typename VALUE>
......@@ -31,7 +31,7 @@ DataPool<VALUE>::DataPool(const EventContext& ctx,
: m_handle (static_cast<SG::ArenaHeader*>(nullptr), ctx, &s_params)
{
if (n > 0)
m_handle.reserve (n);
m_handle.reserve (std::max (n, s_minRefCount));
}
template <typename VALUE>
......@@ -40,7 +40,7 @@ DataPool<VALUE>::DataPool(SG::Arena* arena,
: m_handle (arena, nullptr, &s_params)
{
if (n > 0)
m_handle.reserve (n);
m_handle.reserve (std::max (n, s_minRefCount));
}
//-----------------------------------------------------------
......
......@@ -172,7 +172,7 @@ void ArenaBlock::protect()
int stat = mprotect (this, m_size*m_elt_size+ArenaBlockBodyOffset,
PROT_READ);
if (stat) {
throw SG::ExcProtection (stat);
throw SG::ExcProtection (errno);
}
}
......@@ -188,7 +188,7 @@ void ArenaBlock::unprotect()
int stat = mprotect (this, m_size*m_elt_size+ArenaBlockBodyOffset,
PROT_READ + PROT_WRITE);
if (stat) {
throw SG::ExcProtection (stat);
throw SG::ExcProtection (errno);
}
}
......
......@@ -124,11 +124,8 @@ void ArenaBlockAllocatorBase::reserve (size_t size)
}
if (size > m_stats.elts.total) {
// Growing the pool.
// Make a new block of the required size (but not less than nblock).
// Make a new block of the required size.
size_t sz = size - m_stats.elts.total;
if (sz < m_params.nblock) {
sz = m_params.nblock;
}
ArenaBlock* newblock = ArenaBlock::newBlock (sz, m_params.eltSize,
m_params.constructor);
......
......@@ -57,6 +57,7 @@ InDet::SiTrajectory_xk::convertToTrackStateOnSurface()
{
auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
dtsos->reserve (1 + m_lastElement - m_firstElement);
bool multi = m_tools->multiTrack(); if (m_nclusters <= m_tools->clustersmin() || pTfirst() < m_tools->pTmin()) multi = false;
......@@ -105,6 +106,7 @@ InDet::SiTrajectory_xk::convertToTrackStateOnSurfaceWithNewDirection()
{
auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
dtsos->reserve (1 + m_lastElement - m_firstElement);
bool multi = m_tools->multiTrack(); if (pTfirst() < m_tools->pTmin()) multi = false;
......@@ -157,6 +159,7 @@ Trk::TrackStateOnSurfaceProtContainer::ContainerUniquePtr
InDet::SiTrajectory_xk::convertToSimpleTrackStateOnSurface()
{
auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
dtsos->reserve (2 + m_lastElement - m_firstElement);
int i = m_firstElement;
......@@ -210,6 +213,7 @@ Trk::TrackStateOnSurfaceProtContainer::ContainerUniquePtr
InDet::SiTrajectory_xk::convertToSimpleTrackStateOnSurfaceWithNewDirection()
{
auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
dtsos->reserve (1 + m_lastElement - m_firstElement);
int i = m_lastElement;
......@@ -260,6 +264,7 @@ Trk::TrackStateOnSurfaceProtContainer::ContainerUniquePtr
InDet::SiTrajectory_xk::convertToSimpleTrackStateOnSurfaceForDisTrackTrigger()
{
auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
dtsos->reserve (1 + m_lastElement - m_firstElement);
int i = m_firstElement;
......@@ -2173,12 +2178,14 @@ InDet::SiTrajectory_xk::convertToNextTrackStateOnSurface()
}
auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
dtsos->reserve (m_ntos);
if (i==m_ntos) {
dtsos->elt_allocator().protect();
return dtsos;
}
dtsos->reserve (m_ntos);
for (i=0; i!=m_ntos; ++i) {
auto tsos = m_elements[m_atos[i]].tsos(*dtsos, m_itos[i]);
......
......@@ -556,6 +556,7 @@ Trk::Track* InDet::InDetAmbiTrackSelectionTool::createSubTrack( const std::vecto
}
auto vecTsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
vecTsos->reserve (tsos.size());
// loop over TSOS, copy TSOS and push into vector
for (const Trk::TrackStateOnSurface* tsosIt : tsos) {
......
......@@ -1488,6 +1488,7 @@ Trk::Track* InDet::InDetDenseEnvAmbiTrackSelectionTool::createSubTrack( const st
}
auto vecTsos = Trk::TrackStateOnSurfaceProtContainer::make_unique();
vecTsos->reserve (tsos.size());
// loop over TSOS, copy TSOS and push into vector
for (const Trk::TrackStateOnSurface* iTsos : tsos) {
......
......@@ -356,6 +356,7 @@ Trk::GaussianSumFitter::fit(
// Store only TSOS in tracks instead of MCSOS
if (!m_StoreMCSOS) {
auto slimmedSmoothedTrajectory = Trk::TrackStateOnSurfaceProtContainer::make_unique();
slimmedSmoothedTrajectory->reserve (smoothedTrajectory->size());
for (const Trk::TrackStateOnSurface* tsos : *smoothedTrajectory) {
slimmedSmoothedTrajectory->push_back(slimmedSmoothedTrajectory->allocate(*tsos));
}
......@@ -494,6 +495,7 @@ Trk::GaussianSumFitter::fit(
// Store only TSOS in tracks instead of MCSOS
if (!m_StoreMCSOS) {
auto slimmedSmoothedTrajectory = Trk::TrackStateOnSurfaceProtContainer::make_unique();
slimmedSmoothedTrajectory->reserve (smoothedTrajectory->size());
for (const Trk::TrackStateOnSurface* tsos : *smoothedTrajectory) {
slimmedSmoothedTrajectory->push_back(slimmedSmoothedTrajectory->allocate(*tsos));
}
......@@ -1034,6 +1036,7 @@ Trk::GaussianSumFitter::fit(
* we opt for const ptr*
*/
auto smoothedTrajectory = SmoothedTrajectoryProt::make_unique();
smoothedTrajectory->reserve (5 + forwardTrajectory.size());
auto smootherPredictionMultiState =
std::make_unique<Trk::MultiComponentState>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment