ark::perf::PerfEventHandle

Defined in header “ark/perf/perf_event_handle.hh”.


This is a wrapper around the Linux kernel perf event system. It allows you to stream perf events (at the moment, samples) from the kernel. It will simply return copies of the data being read from the ring buffer it’s up to calling code to parse that into useful samples.

Methods

  • PerfEventHandle(PerfEventHandleConfig config)
    Constructor. Opens a new perf event stream. Follows the same semantics as perf_event_open, in terms of how you define which PID(s) or CPU(s) you want to stream data for.

  • ~PerfEventHandle()
    Destructor. Releases resources associated with the handle.

  • const PerfEventSchema & schema()
    Returns the format/schema of the perf event that this handle is connected to.

  • void enable()
    Enables the perf event handle. At this point, data will start populating the ring buffer.

  • native_handle_type native_handle()
    Returns the underlying native handle for this object.

  • core::ByteBuffer read()
    Reads a block of data from the handle. May return an empty buffer if there is no data to read. This will return a copy of the data, so it is safe to move between threads or hold onto between read() calls.

  • void read(core::ByteBuffer & destination)
    Reads a block of data from the handle into the given byte buffer. May return an empty buffer if there is no data to read. This will copy data from the ring buffer to the end of the given byte buffer (as if ‘write’ was called).