ATLAS Offline Software
CounterThread.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "CounterThread.h"
8 
9 CounterThread::CounterThread(const std::string& name, const MonitorBase* parent)
10  : CounterBase(name, parent), m_lowTimestamp(std::numeric_limits<uint64_t>::max()), m_highTimestamp(0),
11  m_globalLowTimestamp(std::numeric_limits<uint64_t>::max()), m_globalHighTimestamp(0)
12 {
13  regHistogram("AlgTime_perEvent", "Algorithm CPU Time/Event;Time [ms];Events", VariableType::kPerEvent);
14  regHistogram("FrameworkTime_perEvent", "Framework CPU Time/Event;Time [ms];Events", VariableType::kPerEvent);
15  regHistogram("UnmonitoredTime_perEvent", "Unmonitored CPU Time/Event;Time [ms];Events", VariableType::kPerEvent);
16  regHistogram("WallTime_perEvent", "Total walltime from HLT start to stop/Event;Time [ms];Events", VariableType::kPerEvent);
17 
18  regHistogram("AlgTime_perEventFractional", "Algorithm CPU Time Fractional;Fractional Time;Events", VariableType::kPerEvent, kLinear, 0., 1.);
19  regHistogram("FrameworkTime_perEventFractional", "Framework Time/Event CPU Time Fractional;Fractional Time;Events", VariableType::kPerEvent, kLinear, 0., 1.);
20  regHistogram("FrameworkTime_perEventFractional_vs_TotalTime_perEvent", "Framework Fractional Time vs Total Time/Event;Framework Time/Event CPU Time Fractional;Total Time/Event CPU Time Fractional;Events", VariableType::kPerEvent, kLinear, 0., 1., 70, kLog, 0.1, 1000000., 70);
21  regHistogram("AlgTime_perEventFractional_vs_TotalTime_perEvent", "Algorithm Fractional Time vs Total Time/Event;Algorithm Time/Event CPU Time Fractional;Total Time/Event CPU Time Fractional;Events", VariableType::kPerEvent, kLinear, 0., 1., 70, kLog, 0.1, 1000000., 70);
22  regHistogram("UnmonitoredTime_perEventFractional", "Unmonitored CPU Time Fractional;Fractional Time;Events", VariableType::kPerEvent, kLinear, 0., 1.);
23 
24  regHistogram("AlgCalls_perEvent", "Algorithm Calls/Event;Calls;Events", VariableType::kPerEvent, kLog, 0.5, 10000.5, 500);
25  regHistogram("ThisAlgCalls_perEvent", "This Event Algorithm Calls/Event;Calls;Events", VariableType::kPerEvent, kLog, 0.5, 10000.5, 500);
26  regHistogram("OtherAlgCalls_perEvent", "Other Event Algorithm Calls/Event;Calls;Events", VariableType::kPerEvent, kLog, 0.5, 10000.5, 500);
27  regHistogram("AlgSlot_perCall", "Algorithm Slot/Call;Slot;Calls", VariableType::kPerCall, kLinear, -0.5, 20.5, 21);
28 
29 }
30 
31 
33  const xAOD::TrigComposite* alg = data.costCollection().at(index);
34 
35  const uint64_t start = alg->getDetail<uint64_t>("start"); // in mus
36  const uint64_t stop = alg->getDetail<uint64_t>("stop"); // in mus
37  const uint32_t slot = alg->getDetail<uint32_t>("slot");
38  const float cpuTime = timeToMilliSec(start, stop);
39  ATH_CHECK( fill("AlgTime_perEvent", cpuTime, weight) );
40  ATH_CHECK( fill("AlgTime_perEventFractional", cpuTime, weight) );
41  ATH_CHECK( increment("AlgCalls_perEvent", weight) );
42  if (slot == 0) {
43  ATH_CHECK( increment("ThisAlgCalls_perEvent", weight) );
44  } else {
45  ATH_CHECK( increment("OtherAlgCalls_perEvent", weight) );
46  }
47  ATH_CHECK( fill("AlgSlot_perCall", slot, weight) );
50 
51  return StatusCode::SUCCESS;
52 }
53 
55  // Total time from start of HLTSeeding to "stop" of SummaryMaker.
57 
58  // We know that we may loose data on algs which started executing before the HLTSeeding triggered the data collection.
59  // But we truncate the data for algs which are running still when we stop collecting data.
60  float unmonitoredTime = 0;
61  if (m_highTimestamp > 0) {
62  const float unmonitoredStart = timeToMilliSec(m_globalLowTimestamp, m_lowTimestamp);
63  const float unmonitoredEnd = timeToMilliSec(m_highTimestamp, m_globalHighTimestamp);
64  unmonitoredTime = unmonitoredStart + unmonitoredEnd;
65  // As of T12, unmonitoredEnd should be zero due to truncating this record online.
66  }
67 
68  // Time spent outside of any algorithm. E.g. in Gaudi
69  const float frameworkTime = eventTime - unmonitoredTime - getVariable("AlgTime_perEvent").getAccumulator();
70 
71  ATH_CHECK( fill("UnmonitoredTime_perEvent", unmonitoredTime, weight) );
72  ATH_CHECK( fill("UnmonitoredTime_perEventFractional", unmonitoredTime, weight) );
73 
74  ATH_CHECK( fill("FrameworkTime_perEvent", frameworkTime, weight) );
75  ATH_CHECK( fill("FrameworkTime_perEventFractional", frameworkTime, weight) );
76 
77  ATH_CHECK( fill("WallTime_perEvent", eventTime, weight) );
78 
79  ATH_CHECK( setDenominator("AlgTime_perEventFractional", eventTime) );
80  ATH_CHECK( setDenominator("FrameworkTime_perEventFractional", eventTime) );
81  ATH_CHECK( setDenominator("UnmonitoredTime_perEventFractional", eventTime) );
82 
83  ATH_CHECK( fill("FrameworkTime_perEventFractional_vs_TotalTime_perEvent", frameworkTime, eventTime, weight) );
84  ATH_CHECK( fill("AlgTime_perEventFractional_vs_TotalTime_perEvent", getVariable("AlgTime_perEvent").getAccumulator(), eventTime, weight) );
85  ATH_CHECK( setDenominator("FrameworkTime_perEventFractional_vs_TotalTime_perEvent", eventTime) );
86  ATH_CHECK( setDenominator("AlgTime_perEventFractional_vs_TotalTime_perEvent", eventTime) );
87 
89  m_highTimestamp = 0;
92 
93  return StatusCode::SUCCESS;
94 }
95 
96 
98  return m_lowTimestamp;
99 }
100 
101 
103  return m_highTimestamp;
104 }
105 
106 
108  m_globalLowTimestamp = low;
109  m_globalHighTimestamp = high;
110 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CounterBase::setDenominator
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
Definition: CounterBase.cxx:210
CounterBase
Forward declare.
Definition: CounterBase.h:25
CounterBase::regHistogram
void regHistogram(const std::string &name, const std::string &title, const VariableType type=VariableType::kPerCall, const LogType xaxis=kLog, const float min=0.1, const float max=1000000., const size_t bins=70)
Book a histogram for this Counter, to be filled in per-event monitoring.
Definition: CounterBase.cxx:27
SGout2dot.alg
alg
Definition: SGout2dot.py:243
max
#define max(a, b)
Definition: cfImp.cxx:41
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
CounterBase::fill
StatusCode fill(const std::string &name, float value, float weight=1.0)
Fill (for per-Call) or accumulate in a buffer (for per-Event) a quantity histogrammed by a named Vari...
Definition: CounterBase.cxx:191
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
kPerEvent
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:19
CounterThread::m_lowTimestamp
uint64_t m_lowTimestamp
Records the lowest timestamp seen on this single thread in an event.
Definition: CounterThread.h:72
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
CounterThread::postProcess
StatusCode postProcess(float weight=1.0)
Apply post-processing to the Counter, before endEvent is called.
Definition: CounterThread.cxx:54
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
kLog
@ kLog
Logarithmic x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CounterThread::m_highTimestamp
uint64_t m_highTimestamp
Records the highest timestamp seen on this single thread in an event.
Definition: CounterThread.h:73
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
CounterThread::getLowTimestamp
uint64_t getLowTimestamp() const
Get the lowest timestamp of this single thread.
Definition: CounterThread.cxx:97
TrigCompositeContainer.h
min
#define min(a, b)
Definition: cfImp.cxx:40
CounterThread::newEvent
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.0) override
Concrete implementation.
Definition: CounterThread.cxx:32
Variable::getAccumulator
float getAccumulator() const
Getter for accumulated value of a kPerEvent Variable.
Definition: Variable.cxx:34
CounterThread::getHighTimestamp
uint64_t getHighTimestamp() const
Get the highest timestamp of this single thread.
Definition: CounterThread.cxx:102
kPerCall
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:18
CounterBase::getVariable
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
Definition: CounterBase.cxx:182
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
kLinear
@ kLinear
Linear x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:27
MonitorBase
Forward declare.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:33
CounterThread::CounterThread
CounterThread()=delete
Forbid default constructor.
CounterBase::increment
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
Definition: CounterBase.cxx:220
CounterThread::m_globalLowTimestamp
uint64_t m_globalLowTimestamp
Records the lowest timestamp seen over all threads in an event.
Definition: CounterThread.h:75
CounterThread.h
CounterThread::m_globalHighTimestamp
uint64_t m_globalHighTimestamp
Records the highest timestamp seen over all threads in an event.
Definition: CounterThread.h:76
CounterThread::setAllThreadsTimestamps
void setAllThreadsTimestamps(uint64_t low, uint64_t high)
Set the low and high timestamps over all threads.
Definition: CounterThread.cxx:107
CounterBase::timeToMilliSec
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
Definition: CounterBase.cxx:243
CostData
Caches and propagates event data to be used by monitoring algorithms.
Definition: CostData.h:26