Expand description
§perfetto-sdk
Safe and ergonomic Rust bindings for the Perfetto tracing framework.
This crate provides the main API for recording trace data from Rust applications. It wraps the Perfetto C API with safe Rust abstractions for tracing sessions, data sources, and track events.
§Quick start
use perfetto_sdk::track_event::*;
perfetto_sdk::track_event_categories! {
pub mod my_categories {
("rendering", "Rendering events", []),
("input", "Input events", []),
}
}
use my_categories as perfetto_te_ns;
perfetto_sdk::track_event_instant!("rendering", "DrawFrame");§Features
- Track events with categories, names, and typed arguments
- Data sources for custom trace data
- Protozero encoding in pure Rust for minimal overhead
- Tracing sessions for programmatic trace collection
§Crate features
| Feature | Default | Description |
|---|---|---|
vendored | yes | Statically links the bundled Perfetto C library |
intrinsics | no | Enables branch-prediction hints to reduce trace overhead |
§Related crates
| Crate | Description |
|---|---|
perfetto-sdk-sys | Low-level FFI bindings |
perfetto-sdk-derive | Proc macros for function tracing |
perfetto-sdk-protos-gpu | GPU event protobuf bindings |
Modules§
- data_
source - Data source module.
- heap_
buffer - Heap buffer module.
- pb_
decoder - Protobuf decoder module.
- pb_msg
- Protobuf message module.
- pb_
utils - Protobuf utils module.
- producer
- Producer module.
- protos
- Protobuf bindings module.
- stream_
writer - Stream writer module.
- tracing_
session - Tracing session module.
- track_
event - Track event module.
Macros§
- pb_enum
- Defines a protobuf enum.
- pb_msg
- Defines a protobuf message.
- pb_
msg_ ext - Defines extra fields for a protobuf message.
- scoped_
track_ event - Emits a pair of begin/end track events when
categoryis enabled. The end event is emitted when the current scope ends. - trace_
for_ category - Calls
lambdafor each active instance wherecategoryis enabled. - track_
event - Emits a track event when
categoryis enabled. The optionallambdais only called when emitting an event. - track_
event_ begin - Emits a begin track event when
categoryis enabled. - track_
event_ categories - Defines track event categories.
- track_
event_ category_ enabled - Determines if a category is enabled.
- track_
event_ counter - Emits a counter track event when
categoryis enabled. - track_
event_ end - Emits an end track event when
categoryis enabled. - track_
event_ instant - Emits an instant track event when
categoryis enabled. - track_
event_ set_ category_ callback - Sets the callback to invoke when a specific category is enabled.
Functions§
- fnv1a
- Computes the FNV-1a hash of
bytes.