Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::PerfCounters Class Reference

#include <perf-counters.h>

Collaboration diagram for impala::PerfCounters:

Classes

struct  CounterData
 

Public Types

enum  Counter {
  PERF_COUNTER_SW_CPU_CLOCK, PERF_COUNTER_SW_PAGE_FAULTS, PERF_COUNTER_SW_CONTEXT_SWITCHES, PERF_COUNTER_SW_CPU_MIGRATIONS,
  PERF_COUNTER_HW_CPU_CYCLES, PERF_COUNTER_HW_INSTRUCTIONS, PERF_COUNTER_HW_CACHE_HIT, PERF_COUNTER_HW_CACHE_MISSES,
  PERF_COUNTER_HW_BRANCHES, PERF_COUNTER_HW_BRANCH_MISSES, PERF_COUNTER_HW_BUS_CYCLES, PERF_COUNTER_VM_USAGE,
  PERF_COUNTER_VM_PEAK_USAGE, PERF_COUNTER_RESIDENT_SET_SIZE, PERF_COUNTER_BYTES_READ, PERF_COUNTER_BYTES_WRITE,
  PERF_COUNTER_DISK_READ, PERF_COUNTER_DISK_WRITE
}
 

Public Member Functions

bool AddDefaultCounters ()
 
bool AddCounter (Counter)
 
void Snapshot (const std::string &name="")
 
const std::vector< int64_t > * counters (int snapshot) const
 Returns the results of that snapshot. More...
 
const std::vector< std::string > * counter_names () const
 Returns readable names for the added counters. More...
 
void PrettyPrint (std::ostream *out) const
 Prints out the names and results for all snapshots to 'out'. More...
 
 PerfCounters ()
 
 ~PerfCounters ()
 

Private Types

enum  DataSource { SYS_PERF_COUNTER, PROC_SELF_IO, PROC_SELF_STATUS }
 

Private Member Functions

 PerfCounters (const PerfCounters &)
 Copy constructor and assignment not allowed. More...
 
PerfCountersoperator= (const PerfCounters &)
 
bool InitSysCounter (Counter counter)
 
bool InitProcSelfIOCounter (Counter counter)
 
bool InitProcSelfStatusCounter (Counter counter)
 
bool GetSysCounters (std::vector< int64_t > &snapshot)
 
bool GetProcSelfIOCounters (std::vector< int64_t > &snapshot)
 
bool GetProcSelfStatusCounters (std::vector< int64_t > &snapshot)
 

Private Attributes

std::vector< CounterDatacounters_
 
std::vector< std::string > counter_names_
 
std::vector< std::string > snapshot_names_
 
std::vector< std::vector
< int64_t > > 
snapshots_
 
int group_fd_
 

Detailed Description

Definition at line 43 of file perf-counters.h.

Member Enumeration Documentation

Enumerator
PERF_COUNTER_SW_CPU_CLOCK 
PERF_COUNTER_SW_PAGE_FAULTS 
PERF_COUNTER_SW_CONTEXT_SWITCHES 
PERF_COUNTER_SW_CPU_MIGRATIONS 
PERF_COUNTER_HW_CPU_CYCLES 
PERF_COUNTER_HW_INSTRUCTIONS 
PERF_COUNTER_HW_CACHE_HIT 
PERF_COUNTER_HW_CACHE_MISSES 
PERF_COUNTER_HW_BRANCHES 
PERF_COUNTER_HW_BRANCH_MISSES 
PERF_COUNTER_HW_BUS_CYCLES 
PERF_COUNTER_VM_USAGE 
PERF_COUNTER_VM_PEAK_USAGE 
PERF_COUNTER_RESIDENT_SET_SIZE 
PERF_COUNTER_BYTES_READ 
PERF_COUNTER_BYTES_WRITE 
PERF_COUNTER_DISK_READ 
PERF_COUNTER_DISK_WRITE 

Definition at line 45 of file perf-counters.h.

Enumerator
SYS_PERF_COUNTER 
PROC_SELF_IO 
PROC_SELF_STATUS 

Definition at line 107 of file perf-counters.h.

Constructor & Destructor Documentation

impala::PerfCounters::PerfCounters ( )

Definition at line 309 of file perf-counters.cc.

impala::PerfCounters::~PerfCounters ( )

Definition at line 313 of file perf-counters.cc.

References counters_, and SYS_PERF_COUNTER.

impala::PerfCounters::PerfCounters ( const PerfCounters )
private

Copy constructor and assignment not allowed.

Member Function Documentation

bool impala::PerfCounters::AddDefaultCounters ( )

Add the 'default' counters as ones to collect. Returns false if any of those counters are not available. Counters cannot be added after a snapshot has been taken.

Definition at line 322 of file perf-counters.cc.

References AddCounter(), PERF_COUNTER_DISK_READ, PERF_COUNTER_RESIDENT_SET_SIZE, PERF_COUNTER_SW_CPU_CLOCK, PERF_COUNTER_VM_PEAK_USAGE, and PERF_COUNTER_VM_USAGE.

Referenced by impala::TEST().

const std::vector<std::string>* impala::PerfCounters::counter_names ( ) const
inline

Returns readable names for the added counters.

Definition at line 86 of file perf-counters.h.

References counter_names_.

const vector< int64_t > * impala::PerfCounters::counters ( int  snapshot) const

Returns the results of that snapshot.

Definition at line 403 of file perf-counters.cc.

References snapshots_.

bool impala::PerfCounters::GetProcSelfIOCounters ( std::vector< int64_t > &  snapshot)
private

Definition at line 261 of file perf-counters.cc.

References impala::colon, counters_, impala::PROC_IO_LAST_COUNTER, and PROC_SELF_IO.

Referenced by Snapshot().

bool impala::PerfCounters::GetProcSelfStatusCounters ( std::vector< int64_t > &  snapshot)
private

Definition at line 286 of file perf-counters.cc.

References impala::colon, counters_, and PROC_SELF_STATUS.

Referenced by Snapshot().

bool impala::PerfCounters::GetSysCounters ( std::vector< int64_t > &  snapshot)
private

Definition at line 238 of file perf-counters.cc.

References COUNTER_SIZE, counters_, and SYS_PERF_COUNTER.

Referenced by Snapshot().

PerfCounters& impala::PerfCounters::operator= ( const PerfCounters )
private
void impala::PerfCounters::PrettyPrint ( std::ostream *  out) const

Prints out the names and results for all snapshots to 'out'.

Definition at line 408 of file perf-counters.cc.

References counter_names_, counters_, PRETTY_PRINT_WIDTH, impala::PrettyPrinter::Print(), snapshot_names_, and snapshots_.

Referenced by impala::TEST().

void impala::PerfCounters::Snapshot ( const std::string &  name = "")

Take a snapshot of all the counters and store it. The caller can specify a name for the snapshot.

Definition at line 381 of file perf-counters.cc.

References counters_, GetProcSelfIOCounters(), GetProcSelfStatusCounters(), GetSysCounters(), impala::name, snapshot_names_, and snapshots_.

Referenced by impala::TEST().

Member Data Documentation

std::vector<std::string> impala::PerfCounters::counter_names_
private

Definition at line 130 of file perf-counters.h.

Referenced by AddCounter(), counter_names(), and PrettyPrint().

int impala::PerfCounters::group_fd_
private

System perf counters can be grouped together. The OS will update all grouped counters at the same time. This is useful to better correlate counter values.

Definition at line 135 of file perf-counters.h.

Referenced by InitSysCounter().

std::vector<std::string> impala::PerfCounters::snapshot_names_
private

Definition at line 131 of file perf-counters.h.

Referenced by PrettyPrint(), and Snapshot().

std::vector<std::vector<int64_t> > impala::PerfCounters::snapshots_
private

Definition at line 132 of file perf-counters.h.

Referenced by counters(), PrettyPrint(), and Snapshot().


The documentation for this class was generated from the following files: