ATLAS Offline Software
|
Clean conditions containers after a delay. More...
#include <DelayedConditionsCleanerSvc.h>
Classes | |
class | CondContInfo |
Information that we maintain about each conditions container. More... | |
struct | QueueItem |
Item in the work queue. More... | |
Public Types | |
typedef CondContBase::key_type | key_type |
Packed key type. More... | |
Public Member Functions | |
DelayedConditionsCleanerSvc (const std::string &name, ISvcLocator *svc) | |
Standard Gaudi constructor. More... | |
~DelayedConditionsCleanerSvc () | |
Standard destructor. More... | |
virtual StatusCode | initialize () override |
Standard Gaudi initialize method. More... | |
virtual StatusCode | finalize () override |
Standard Gaudi finalize method. More... | |
virtual StatusCode | event (const EventContext &ctx, bool allowAsync) override |
Called at the start of each event. More... | |
virtual StatusCode | condObjAdded (const EventContext &ctx, CondContBase &cc) override |
Called after a conditions object has been added. More... | |
virtual StatusCode | printStats () const override |
Print some statistics about the garbage collection. More... | |
virtual StatusCode | reset () override |
Clear the internal state of the service. More... | |
Private Types | |
typedef CxxUtils::Ring< key_type > | Ring |
Ring buffer holding most recent IOV keys of a given type. More... | |
using | KeyType = CondContBase::KeyType |
Run+LBN or timestamp key? More... | |
typedef std::array< std::vector< key_type >, 2 > | twoKeys_t |
typedef std::unordered_map< CondContBase *, CondContInfo > | CCInfoMap_t |
Map of information, indexed by the conditions container. More... | |
typedef std::mutex | mutex_t |
Serialize access to m_ccinfo and m_work. More... | |
typedef std::lock_guard< mutex_t > | lock_t |
Private Member Functions | |
twoKeys_t | getKeys (const Ring &runLBRing, const Ring &TSRing) const |
void | scheduleClean (std::vector< CondContInfo * > &&cis, twoKeys_t &&twoKeys, bool allowAsync) |
Do cleaning for a set of containers. More... | |
void | cleanContainers (std::vector< CondContInfo * > &&cis, twoKeys_t &&twoKeys) |
Clean a set of containers. More... | |
bool | cleanContainer (CondContInfo *ci, const twoKeys_t &keys) const |
Clean a single container. More... | |
Private Attributes | |
Ring | m_runlbn |
Two ring buffers for recent IOV keys, one for run+LBN and one for timestamp. More... | |
Ring | m_timestamp |
std::vector< key_type > | m_slotLBN |
IOV keys currently in use for each slot. More... | |
std::vector< key_type > | m_slotTimestamp |
CCInfoMap_t | m_ccinfo |
std::priority_queue< QueueItem > | m_work |
Priority queue of pending cleaning requests. More... | |
mutex_t | m_workMutex |
size_t | m_nEvents = 0 |
Priority queue statistics. More... | |
size_t | m_queueSum = 0 |
size_t | m_workRemoved = 0 |
size_t | m_maxQueue = 0 |
std::atomic< int > | m_cleanTasks {0} |
Number of active asynchronous cleaning tasks. More... | |
std::unique_ptr< DelayedConditionsCleanerSvcProps > | m_props |
Component properties. More... | |
Friends | |
class | DelayedConditionsCleanerTask |
Clean conditions containers after a delay.
This is an implementation of IConditionsCleanerSvc, for doing garbage collection of conditions objects.
Briefly, it works like this.
When a conditions object is added (condObjAdded
interface), we put an entry in a priority queue, saying that we want to clean this container CleanDelay events later.
On each event (event
interface) we put the current IOV keys (run+LBN and timestamp) into ring buffers (of size RingSize). If the topmost entry of the priority queue has come due, then we pull off that entry and other entries due up to LookAhead events later. We then do a trim operation on each of the conditions containers, removing conditions objects from the oldest first that do not match any of the IOV keys in the ring buffer.
The cleaning can optionally be done as an asynchronous TBB job if Async is true and allowAsync=true is passed to event
.
Definition at line 57 of file DelayedConditionsCleanerSvc.h.
|
private |
Map of information, indexed by the conditions container.
Definition at line 214 of file DelayedConditionsCleanerSvc.h.
Packed key type.
Definition at line 62 of file DelayedConditionsCleanerSvc.h.
|
private |
Run+LBN or timestamp key?
Definition at line 133 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 241 of file DelayedConditionsCleanerSvc.h.
|
private |
Serialize access to m_ccinfo and m_work.
Definition at line 240 of file DelayedConditionsCleanerSvc.h.
|
private |
Ring buffer holding most recent IOV keys of a given type.
Definition at line 129 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 135 of file DelayedConditionsCleanerSvc.h.
Athena::DelayedConditionsCleanerSvc::DelayedConditionsCleanerSvc | ( | const std::string & | name, |
ISvcLocator * | svc | ||
) |
Athena::DelayedConditionsCleanerSvc::~DelayedConditionsCleanerSvc | ( | ) |
Standard destructor.
Needed to avoid problems with unique_ptr
Definition at line 493 of file DelayedConditionsCleanerSvc.cxx.
|
private |
Clean a single container.
ci | The container to clean. |
keys | Set of IOV keys for recent events. |
Returns true if anything was removed from the container,
ci | The container to clean. |
keyType | Run+LBN or timestamp keys? |
keys | Set of IOV keys for recent events. |
Returns true if anything was removed from the container,
Definition at line 468 of file DelayedConditionsCleanerSvc.cxx.
|
private |
Clean a set of containers.
cis | Set of containers to clean. |
keys | Set of IOV keys for recent events. |
Definition at line 423 of file DelayedConditionsCleanerSvc.cxx.
|
overridevirtual |
Called after a conditions object has been added.
ctx | The current event context. |
cc | The container to which the object was added. |
Definition at line 256 of file DelayedConditionsCleanerSvc.cxx.
|
overridevirtual |
Called at the start of each event.
ctx | The current event context. |
allowAsync | If true, then cleaning may be run in an asynchronous TBB task. |
Definition at line 188 of file DelayedConditionsCleanerSvc.cxx.
|
overridevirtual |
Standard Gaudi finalize method.
Definition at line 498 of file DelayedConditionsCleanerSvc.cxx.
|
private |
Sort the key array and remove duplicates. We expect that the key array is probably ‘almost’ sorted. std::sort, at least in the gcc implementation, is designed to perform well in such cases.
Definition at line 345 of file DelayedConditionsCleanerSvc.cxx.
|
overridevirtual |
|
overridevirtual |
Print some statistics about the garbage collection.
Would generally be called in finalize(), but broken out as a separate interface for testing/debugging purposes.
Definition at line 277 of file DelayedConditionsCleanerSvc.cxx.
|
overridevirtual |
Clear the internal state of the service.
Only for testing. Don't call if any other thread may be touching the service.
Definition at line 322 of file DelayedConditionsCleanerSvc.cxx.
|
private |
Do cleaning for a set of containers.
cis | Set of containers to clean. |
ring | Ring buffer with recent IOV keys. |
slotKeys | Vector of current keys for all slots. |
allowAsync | Can this task run asynchronously? |
This will either run cleaning directly, or submit it as a TBB task.
Definition at line 386 of file DelayedConditionsCleanerSvc.cxx.
|
friend |
Definition at line 125 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 215 of file DelayedConditionsCleanerSvc.h.
|
private |
Number of active asynchronous cleaning tasks.
Definition at line 253 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 249 of file DelayedConditionsCleanerSvc.h.
|
private |
Priority queue statistics.
Definition at line 246 of file DelayedConditionsCleanerSvc.h.
|
private |
Component properties.
Definition at line 256 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 247 of file DelayedConditionsCleanerSvc.h.
|
private |
Two ring buffers for recent IOV keys, one for run+LBN and one for timestamp.
We only access these from event(), which is called from the event loop, so no locking is needed.
Definition at line 205 of file DelayedConditionsCleanerSvc.h.
|
private |
IOV keys currently in use for each slot.
Definition at line 209 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 210 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 206 of file DelayedConditionsCleanerSvc.h.
|
private |
Priority queue of pending cleaning requests.
Definition at line 237 of file DelayedConditionsCleanerSvc.h.
|
mutableprivate |
Definition at line 242 of file DelayedConditionsCleanerSvc.h.
|
private |
Definition at line 248 of file DelayedConditionsCleanerSvc.h.