Skip to content

Commit

Permalink
DPL Analysis: mitigate memory spike while writing histograms
Browse files Browse the repository at this point in the history
This is an attempt to mitigate the memory spike at the end of the
processing.
  • Loading branch information
ktf committed Aug 9, 2023
1 parent cb20ee1 commit 60a6ba8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Framework/Core/include/Framework/AnalysisManagers.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ struct OutputManager<HistogramRegistry> {

static bool postRun(EndOfStreamContext& context, HistogramRegistry& what)
{
context.outputs().snapshot(what.ref(), *(*what));
context.outputs().snapshot(what.ref(), *(what.getListOfHistograms()));
what.clean();
return true;
}
};
Expand Down
6 changes: 5 additions & 1 deletion Framework/Core/include/Framework/HistogramRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ class HistogramRegistry

void setHash(uint32_t hash);

TList* operator*();
/// returns the list of histograms, properly sorted for writing.
TList* getListOfHistograms();

/// deletes all the histograms from the registry
void clean();

// fill hist with values
template <typename... Ts>
Expand Down
9 changes: 8 additions & 1 deletion Framework/Core/src/HistogramRegistry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ double HistogramRegistry::getSize(double fillFraction)
return size;
}

void HistogramRegistry::clean()
{
for (auto& value : mRegistryValue) {
std::visit([](auto&& hist) { hist.reset(); }, value);
}
}

// print some useful meta-info about the stored histograms
void HistogramRegistry::print(bool showAxisDetails)
{
Expand Down Expand Up @@ -272,7 +279,7 @@ void HistogramRegistry::print(bool showAxisDetails)
}

// create output structure will be propagated to file-sink
TList* HistogramRegistry::operator*()
TList* HistogramRegistry::getListOfHistograms()
{
TList* list = new TList();
list->SetName(mName.data());
Expand Down

0 comments on commit 60a6ba8

Please sign in to comment.