pub struct PerfSample {
pub cpu: Option<u32>,
pub pid: Option<u32>,
pub tid: Option<u32>,
pub cpu_mode: Option<i32>,
pub timebase_count: Option<u64>,
pub follower_counts: Vec<u64>,
pub callstack_iid: Option<u64>,
pub kernel_records_lost: Option<u64>,
pub producer_event: Option<ProducerEvent>,
pub optional_unwind_error: Option<OptionalUnwindError>,
pub optional_sample_skipped_reason: Option<OptionalSampleSkippedReason>,
}
Expand description
Packet emitted by the traced_perf sampling performance profiler, which gathers data via the perf_event_open syscall. Each packet contains an individual sample with a counter value, and optionally a callstack.
Timestamps are within the root packet. The config can specify the clock, or the implementation will default to CLOCK_MONOTONIC_RAW. Within the Android R timeframe, the default was CLOCK_BOOTTIME.
There are several distinct views of this message:
- indication of kernel buffer data loss (kernel_records_lost set)
- indication of skipped samples (sample_skipped_reason set)
- notable event in the sampling implementation (producer_event set)
- normal sample (timebase_count set, typically also callstack_iid)
Fields§
§cpu: Option<u32>
§pid: Option<u32>
§tid: Option<u32>
§cpu_mode: Option<i32>
Execution state that the process was sampled at.
timebase_count: Option<u64>
Value of the timebase counter (since the event was configured, no deltas).
follower_counts: Vec<u64>
Value of the followers counter (since the event was configured, no deltas).
callstack_iid: Option<u64>
Unwound callstack. Might be partial, in which case a synthetic “error” frame is appended, and |unwind_error| is set accordingly.
kernel_records_lost: Option<u64>
If set, indicates that this message is not a sample, but rather an indication of data loss in the ring buffer allocated for |cpu|. Such data loss occurs when the kernel has insufficient ring buffer capacity to write a record (which gets discarded). A record in this context is an individual ring buffer entry, and counts more than just sample records.
The |timestamp| of the packet corresponds to the time that the producer wrote the packet for trace-sorting purposes alone, and should not be interpreted relative to the sample timestamps. This field is sufficient to detect that some kernel data loss happened within the trace, but not the specific time bounds of that loss (which would require tracking precedessor & successor timestamps, which is not deemed necessary at the moment).
producer_event: Option<ProducerEvent>
§optional_unwind_error: Option<OptionalUnwindError>
If set, stack unwinding was incomplete due to an error. Unset values should be treated as UNWIND_ERROR_NONE.
optional_sample_skipped_reason: Option<OptionalSampleSkippedReason>
Implementations§
Source§impl PerfSample
impl PerfSample
Sourcepub fn callstack_iid(&self) -> u64
pub fn callstack_iid(&self) -> u64
Returns the value of callstack_iid
, or the default value if callstack_iid
is unset.
Sourcepub fn cpu_mode(&self) -> CpuMode
pub fn cpu_mode(&self) -> CpuMode
Returns the enum value of cpu_mode
, or the default if the field is unset or set to an invalid enum value.
Sourcepub fn set_cpu_mode(&mut self, value: CpuMode)
pub fn set_cpu_mode(&mut self, value: CpuMode)
Sets cpu_mode
to the provided enum value.
Sourcepub fn timebase_count(&self) -> u64
pub fn timebase_count(&self) -> u64
Returns the value of timebase_count
, or the default value if timebase_count
is unset.
Sourcepub fn kernel_records_lost(&self) -> u64
pub fn kernel_records_lost(&self) -> u64
Returns the value of kernel_records_lost
, or the default value if kernel_records_lost
is unset.
Trait Implementations§
Source§impl Clone for PerfSample
impl Clone for PerfSample
Source§fn clone(&self) -> PerfSample
fn clone(&self) -> PerfSample
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PerfSample
impl Debug for PerfSample
Source§impl Default for PerfSample
impl Default for PerfSample
Source§impl Message for PerfSample
impl Message for PerfSample
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
.