ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
xAOD::IOStats Class Reference

Singleton object holding on to the process's I/O statistics. More...

#include <IOStats.h>

Collaboration diagram for xAOD::IOStats:

Public Member Functions

ReadStatsstats ()
 Access the object belonging to the current thread. More...
 
ReadStats merged () const
 Access the statistics object, merging information from all threads. More...
 

Static Public Member Functions

static IOStatsinstance ()
 Singleton object accessor. More...
 

Private Member Functions

 IOStats ()
 The constructor of the object is made private. More...
 
 IOStats (const IOStats &)=delete
 The copy constructor is deleted. More...
 

Private Attributes

std::map< std::thread::id, ReadStatsm_stats
 Objects describing the file access pattern, per thread. More...
 
AthContainers_detail::thread_specific_ptr< ReadStatsm_ptr
 Thread specific pointer to the ReadStats object of the current thread. More...
 
std::mutex m_mutex
 Mutex for accessing the read statistics. More...
 

Detailed Description

Singleton object holding on to the process's I/O statistics.

This singleton class holds the xAOD file access statistics object describing the auxiliary variable access pattern of the current process.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 34 of file IOStats.h.

Constructor & Destructor Documentation

◆ IOStats() [1/2]

xAOD::IOStats::IOStats ( )
private

The constructor of the object is made private.

Definition at line 49 of file IOStats.cxx.

50  : m_stats(),
51  // Make sure that the thread specific pointer doesn't try to delete
52  // the object it points to when the thread ends:
53  m_ptr( []( ReadStats* ){} ),
54  m_mutex() {
55 
56  }

◆ IOStats() [2/2]

xAOD::IOStats::IOStats ( const IOStats )
privatedelete

The copy constructor is deleted.

Member Function Documentation

◆ instance()

IOStats & xAOD::IOStats::instance ( )
static

Singleton object accessor.

Definition at line 11 of file IOStats.cxx.

11  {
12 
14  return obj;
15  }

◆ merged()

ReadStats xAOD::IOStats::merged ( ) const

Access the statistics object, merging information from all threads.

This function should only be used during the finalisation of a process, once all the event processing threads have already finished. That's because it's not absolutely thread-safe. If another thread modifies an xAOD::ReadStats object through the stats() function while this function is executing, that can possibly lead to a crash.

In the end the function is not made thread safe, because doing so would require the stats() function to be made slower.

Returns
The merged statistics from all executing threads

Definition at line 34 of file IOStats.cxx.

34  {
35 
36  // Get a lock on the map:
37  std::lock_guard< std::mutex > lock( m_mutex );
38 
39  // Merge the objects from all the threads:
40  ReadStats result;
41  for( const auto & pair : m_stats ) {
42  result += pair.second;
43  }
44 
45  // Return the merged object:
46  return result;
47  }

◆ stats()

ReadStats & xAOD::IOStats::stats ( )

Access the object belonging to the current thread.

Components collecting information should always use this function. It is safe to be called at any point during the process, from any thread, without any outside protection.

Returns
A thread specific xAOD::ReadStat object that can be modified

Definition at line 17 of file IOStats.cxx.

17  {
18 
19  // Try to access a cached pointer:
20  ReadStats* stats = m_ptr.get();
21 
22  // If a pointer is not cached yet, do so now:
23  if( ! stats ) {
24  const std::thread::id id = std::this_thread::get_id();
25  std::lock_guard< std::mutex > lock( m_mutex );
26  stats = &( m_stats[ id ] );
27  m_ptr.reset( stats );
28  }
29 
30  // Return the (now) cached object:
31  return *stats;
32  }

Member Data Documentation

◆ m_mutex

std::mutex xAOD::IOStats::m_mutex
mutableprivate

Mutex for accessing the read statistics.

Definition at line 78 of file IOStats.h.

◆ m_ptr

AthContainers_detail::thread_specific_ptr< ReadStats > xAOD::IOStats::m_ptr
private

Thread specific pointer to the ReadStats object of the current thread.

Definition at line 75 of file IOStats.h.

◆ m_stats

std::map< std::thread::id, ReadStats > xAOD::IOStats::m_stats
private

Objects describing the file access pattern, per thread.

Definition at line 72 of file IOStats.h.


The documentation for this class was generated from the following files:
xAOD::IOStats::m_ptr
AthContainers_detail::thread_specific_ptr< ReadStats > m_ptr
Thread specific pointer to the ReadStats object of the current thread.
Definition: IOStats.h:75
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::IOStats::stats
ReadStats & stats()
Access the object belonging to the current thread.
Definition: IOStats.cxx:17
xAOD::IOStats::IOStats
IOStats()
The constructor of the object is made private.
Definition: IOStats.cxx:49
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
xAOD::IOStats::m_mutex
std::mutex m_mutex
Mutex for accessing the read statistics.
Definition: IOStats.h:78
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::IOStats::m_stats
std::map< std::thread::id, ReadStats > m_stats
Objects describing the file access pattern, per thread.
Definition: IOStats.h:72