ATLAS Offline Software
Loading...
Searching...
No Matches
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
9CounterThread::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
32StatusCode CounterThread::newEvent(const CostData& data, size_t index, const float weight) {
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) );
48 m_lowTimestamp = std::min(m_lowTimestamp, start);
49 m_highTimestamp = std::max(m_highTimestamp, stop);
50
51 return StatusCode::SUCCESS;
52}
53
54StatusCode CounterThread::postProcess(float weight) {
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
88 m_lowTimestamp = std::numeric_limits<uint64_t>::max();
90 m_globalLowTimestamp = std::numeric_limits<uint64_t>::max();
92
93 return StatusCode::SUCCESS;
94}
95
96
98 return m_lowTimestamp;
99}
100
101
103 return m_highTimestamp;
104}
105
106
107void CounterThread::setAllThreadsTimestamps(uint64_t low, uint64_t high) {
110}
#define ATH_CHECK
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition Variable.h:19
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition Variable.h:18
@ kLinear
Linear x-binning.
Definition Variable.h:27
@ kLog
Logarithmic x-binning.
Definition Variable.h:28
#define max(a, b)
Definition cfImp.cxx:41
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
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...
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
CounterBase()=delete
Forbid default constructor.
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.
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
StatusCode postProcess(float weight=1.0)
Apply post-processing to the Counter, before endEvent is called.
uint64_t m_globalLowTimestamp
Records the lowest timestamp seen over all threads in an event.
CounterThread()=delete
Forbid default constructor.
uint64_t getLowTimestamp() const
Get the lowest timestamp of this single thread.
uint64_t getHighTimestamp() const
Get the highest timestamp of this single thread.
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.0) override
Concrete implementation.
uint64_t m_highTimestamp
Records the highest timestamp seen on this single thread in an event.
uint64_t m_lowTimestamp
Records the lowest timestamp seen on this single thread in an event.
uint64_t m_globalHighTimestamp
Records the highest timestamp seen over all threads in an event.
void setAllThreadsTimestamps(uint64_t low, uint64_t high)
Set the low and high timestamps over all threads.
float getAccumulator() const
Getter for accumulated value of a kPerEvent Variable.
Definition Variable.cxx:34
Definition index.py:1
STL namespace.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.