Expand description
A parser for the perf.data file format.
Files of this format consist of a header, a data section, and a few other supplemental sections. The data section contains the main content of the file: a sequence of records.
There are two types of records: event records from the kernel, and “user records” from perf / simpleperf.
The jitdump
module lets you parse jitdump files, which are used in
conjunction with perf.data files when profiling JIT runtimes.
§Example
use linux_perf_data::{AttributeDescription, PerfFileReader, PerfFileRecord};
let file = std::fs::File::open("perf.data")?;
let reader = std::io::BufReader::new(file);
let PerfFileReader { mut perf_file, mut record_iter } = PerfFileReader::parse_file(reader)?;
let event_names: Vec<_> =
perf_file.event_attributes().iter().filter_map(AttributeDescription::name).collect();
println!("perf events: {}", event_names.join(", "));
while let Some(record) = record_iter.next_record(&mut perf_file)? {
match record {
PerfFileRecord::EventRecord { attr_index, record } => {
let record_type = record.record_type;
let parsed_record = record.parse()?;
println!("{:?} for event {}: {:?}", record_type, attr_index, parsed_record);
}
PerfFileRecord::UserRecord(record) => {
let record_type = record.record_type;
let parsed_record = record.parse()?;
println!("{:?}: {:?}", record_type, parsed_record);
}
}
}
Re-exports§
pub use linux_perf_event_reader;
pub use prost;
Modules§
- jitdump
- Parsing code for jitdump files.
- simpleperf_
dso_ type - Constants used in
SimpleperfFileRecord
’stype
property.
Structs§
- Attribute
Description - A single event attr with name and corresponding event IDs.
- DsoInfo
- The file path and the build ID of a DSO.
- Feature
- A piece of optional data stored in a perf.data file. Its data is contained in a “feature section” at the end of the file.
- Feature
Set - The set of features used in the perf file. The perf file contains one feature section for each feature.
- Feature
SetIter - An iterator over all the features that are included in a
FeatureSet
, ordered from low to high feature bit. - NrCpus
- The number of available and online CPUs. (
nr_cpus
) - Perf
File - Contains the information from the perf.data file header and feature sections.
- Perf
File Reader - A parser for the perf.data file format.
- Perf
Record Iter - An iterator which incrementally reads and sorts the records from a perf.data file.
- RawUser
Record - A raw user record.
- Sample
Time Range - The timestamps of the first and last sample.
- Simpleperf
DexFile Info - DEX-specific info inside a
SimpleperfFileRecord
. - Simpleperf
ElfFile Info - ELF object specific info inside a
SimpleperfFileRecord
. - Simpleperf
File Record - Used in the
SIMPLEPERF_FILE
andSIMPLEPERF_FILE2
section. - Simpleperf
Kernel Module Info - Kernel module specific info inside a
SimpleperfFileRecord
. - Simpleperf
Symbol - A single symbol, contained in the symbol table inside a
SimpleperfFileRecord
. - Thread
Map - A list of threads, usually without names.
- User
Record Type - A newtype wrapping
RecordType
values for whichRecordType::is_user_type()
returns true.
Enums§
- DsoKey
- A canonicalized key which can be used to cross-reference an Mmap record with an entry in the perf file’s build ID list.
- Endianness
- An enum for little or big endian.
- Error
- The error type used in this crate.
- Perf
File Record - A record from a perf.data file’s data stream.
- Read
Error - This error indicates that the data slice was not large enough to read the respective item.
- Simpleperf
Type Specific Info - Type-specif info inside a
SimpleperfFileRecord
. - User
Record - A record emitted by a user space tool, for example by
perf
or bysimpleperf
.