tracing_perfetto_sdk_schema

Struct PerfSample

Source
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

Source

pub fn cpu(&self) -> u32

Returns the value of cpu, or the default value if cpu is unset.

Source

pub fn pid(&self) -> u32

Returns the value of pid, or the default value if pid is unset.

Source

pub fn tid(&self) -> u32

Returns the value of tid, or the default value if tid is unset.

Source

pub fn callstack_iid(&self) -> u64

Returns the value of callstack_iid, or the default value if callstack_iid is unset.

Source

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.

Source

pub fn set_cpu_mode(&mut self, value: CpuMode)

Sets cpu_mode to the provided enum value.

Source

pub fn timebase_count(&self) -> u64

Returns the value of timebase_count, or the default value if timebase_count is unset.

Source

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

Source§

fn clone(&self) -> PerfSample

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PerfSample

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PerfSample

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for PerfSample

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for PerfSample

Source§

fn eq(&self, other: &PerfSample) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PerfSample

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.