|
ATLAS Offline Software
|
Go to the documentation of this file.
17 #include "GaudiKernel/EventContext.h"
18 #include "GaudiKernel/ServiceHandle.h"
20 #include <unordered_set>
30 #define USE_ASYNC_TASK 0
50 {
parent(),
"RingSize", 100,
51 "Number of previous events for which to remember IOV history." };
56 {
parent(),
"CleanDelay", 100,
57 "Number of events after adding a conditions object we try to clean its container." };
61 {
parent(),
"LookAhead", 10,
62 "Maximum number of events to consolodate together when cleaning." };
68 {
parent(),
"Async",
false,
69 "If true, run cleaning asynchronously in an MT job." };
76 {
parent(),
"RCUSvc",
"Athena::RCUSvc",
85 class DelayedConditionsCleanerTask
96 DelayedConditionsCleanerTask (DelayedConditionsCleanerSvc&
cleaner,
97 std::vector<DelayedConditionsCleanerSvc::CondContInfo*>&& cis,
108 DelayedConditionsCleanerSvc& m_cleaner;
111 std::vector<DelayedConditionsCleanerSvc::CondContInfo*> m_cis;
124 DelayedConditionsCleanerTask::DelayedConditionsCleanerTask
125 (DelayedConditionsCleanerSvc&
cleaner,
126 std::vector<DelayedConditionsCleanerSvc::CondContInfo*>&& cis,
141 m_cleaner.cleanContainers (std::move (m_cis), std::move (m_keys));
144 --m_cleaner.m_cleanTasks;
147 #endif // USE_ASYNC_TASK
173 size_t nslots =
m_props->m_rcu->getNumSlots();
177 return StatusCode::SUCCESS;
196 EventContext::ContextID_t slot = ctx.slot();
197 if (slot != EventContext::INVALID_CONTEXT_ID) {
206 return StatusCode::SUCCESS;
210 std::vector<CondContInfo*> ci_vec;
214 if (!
m_work.empty() &&
m_work.top().m_evt <= ctx.evt()) {
231 ci_vec.push_back (ci);
243 if (!ci_vec.empty()) {
247 return StatusCode::SUCCESS;
266 EventContext::ContextEvt_t
evt = ctx.evt();
268 return StatusCode::SUCCESS;
281 return StatusCode::SUCCESS;
292 std::vector<const CondContInfo*> infos;
294 infos.push_back (&
p.second);
296 std::sort (infos.begin(), infos.end(),
298 { return a->m_cc.id().key() < b->m_cc.id().key(); });
302 ci->m_cc.id().key().c_str(),
304 ci->m_cc.maxSize()) );
308 static_cast<float> (ci->m_nRemoved) / den,
311 ci->m_removed2plus) );
314 return StatusCode::SUCCESS;
331 std::priority_queue<QueueItem>
tmp;
340 return StatusCode::SUCCESS;
348 std::vector<key_type> runLBKeys=runLBRing.
getKeysDedup();
366 std::sort (
keys.begin(),
keys.end());
391 std::sort (cis.begin(), cis.end());
392 auto pos = std::unique (cis.begin(), cis.end());
393 cis.resize (
pos - cis.begin());
395 if (allowAsync &&
m_props->m_async) {
403 tbb::task*
t =
new (tbb::task::allocate_root())
405 std::move (twoKeys));
406 tbb::task::enqueue (*
t);
435 std::vector<CondContInfo*> toclean = std::move (cis);
436 std::unordered_set<CondContInfo*> cleaned (toclean.begin(), toclean.end());
437 while (!toclean.empty()) {
438 std::vector<CondContInfo*> newclean;
447 if (cleaned.insert (ci_dep).second) {
448 newclean.push_back (ci_dep);
454 toclean = std::move (newclean);
471 size_t n = ci->
m_cc.
trim (twoKeys[0],twoKeys[1]);
501 return StatusCode::SUCCESS;
JetConstituentVector::iterator iterator
void cleanContainers(std::vector< CondContInfo * > &&cis, twoKeys_t &&twoKeys)
Clean a set of containers.
static key_type keyFromTimestamp(const EventIDBase &b)
Make a timestamp key from an EventIDBase.
DelayedConditionsCleanerSvcProps(DelayedConditionsCleanerSvc *parent)
std::vector< key_type > m_slotLBN
IOV keys currently in use for each slot.
Hold mappings of ranges to condition objects.
Clean conditions containers after a delay.
std::vector< T > getKeysDedup() const
Return a copy of keys in the buffer.
bool m_async
Property: If true, run cleaning asynchronously in an MT job.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
~DelayedConditionsCleanerSvc()
Standard destructor.
@ RUNLBN
Container uses run+lbn keys.
static key_type keyFromRunLBN(const EventIDBase &b)
Make a run+lbn key from an EventIDBase.
size_t m_removed2plus
Number of times two or more objects were removed.
std::array< std::vector< key_type >, 2 > twoKeys_t
twoKeys_t getKeys(const Ring &runLBRing, const Ring &TSRing) const
Gaudi::Property< size_t > m_ringSize
Property: Number of previous events for which to remember IOV history.
KeyType keyType() const
Return the key type for this container.
std::vector< CondContBase * > getDeps()
Return the list of conditions containers that depend on this one.
ServiceHandle< Athena::IRCUSvc > m_rcu
Property: RCU Service.
virtual StatusCode condObjAdded(const EventContext &ctx, CondContBase &cc) override
Called after a conditions object has been added.
void reset(size_t size)
Clear the buffer and set its size.
std::vector< key_type > m_slotTimestamp
read-copy-update (RCU) style synchronization for Athena.
friend class DelayedConditionsCleanerTask
virtual size_t trim(const std::vector< key_type > &runLbnKeys, const std::vector< key_type > &TSKeys)
Remove unused entries from the front of the list.
pimpl-style holder for component properties.
Information that we maintain about each conditions container.
size_t m_removed0
Number of times exactly 0 objects were removed.
size_t m_removed1
Number of times exactly 1 object was removed.
Some weak symbol referencing magic...
::StatusCode StatusCode
StatusCode definition for legacy code.
Base class for all conditions containers.
size_t m_nEvents
Priority queue statistics.
@ TIMESTAMP
Container uses timestamp keys.
void scheduleClean(std::vector< CondContInfo * > &&cis, twoKeys_t &&twoKeys, bool allowAsync)
Do cleaning for a set of containers.
AthROOTErrorHandlerSvc * svc
std::priority_queue< QueueItem > m_work
Priority queue of pending cleaning requests.
virtual StatusCode printStats() const override
Print some statistics about the garbage collection.
DelayedConditionsCleanerSvc(const std::string &name, ISvcLocator *svc)
Standard Gaudi constructor.
void fill(H5::Group &out_file, size_t iterations)
size_t m_nClean
Number of times cleaning was attempted.
std::lock_guard< mutex_t > lock_t
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
pimpl-style holder for component properties.
std::unique_ptr< DelayedConditionsCleanerSvcProps > m_props
Component properties.
@ MIXED
Mixed Run+lbn / timestamp container.
virtual StatusCode event(const EventContext &ctx, bool allowAsync) override
Called at the start of each event.
std::atomic< int > m_cleanTasks
Number of active asynchronous cleaning tasks.
bool cleanContainer(CondContInfo *ci, const twoKeys_t &keys) const
Clean a single container.
Clean conditions containers after a delay.
virtual StatusCode finalize() override
Standard Gaudi finalize method.
Ring m_runlbn
Two ring buffers for recent IOV keys, one for run+LBN and one for timestamp.
Gaudi::Property< size_t > m_lookAhead
Property: Maximum number of events to consolodate together when cleaning.
CondContBase::key_type key_type
Packed key type.
void push(const T &x)
Add a new item to the buffer.
DelayedConditionsCleanerSvc * parent()
Gaudi::Property< size_t > m_cleanDelay
Property: Number of events after adding a conditions object we try to clean its container.
virtual StatusCode reset() override
Clear the internal state of the service.
@ SINGLE
Either TIMESTAMP or RUNLBN, but nothing's been put in the container yet, so we don't know which one.
CondContBase & m_cc
The conditions container.
size_t m_nRemoved
Total number of objects removed by cleaning.