Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/runner-shared/src/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ impl std::fmt::Debug for DebugInfo {
}
}

/// Per-pid mounting info referencing a deduplicated debug info entry.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MappedProcessDebugInfo {
pub debug_info_key: String,
pub load_bias: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModuleDebugInfo {
/// The path to the object file on disk (e.g. `/usr/lib/libc.so.6`)
Expand Down
1 change: 1 addition & 0 deletions crates/runner-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod artifacts;
pub mod debug_info;
pub mod fifo;
pub mod metadata;
pub mod module_symbols;
pub mod perf_event;
pub mod unwind_data;
pub mod walltime_results;
51 changes: 46 additions & 5 deletions crates/runner-shared/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,74 @@
use anyhow::Context;
use libc::pid_t;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::io::BufWriter;
use std::path::Path;
use std::path::PathBuf;

use crate::debug_info::ModuleDebugInfo;
use crate::debug_info::{MappedProcessDebugInfo, ModuleDebugInfo};
use crate::fifo::MarkerType;
use crate::module_symbols::MappedProcessModuleSymbols;
use crate::unwind_data::MappedProcessUnwindData;

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Default)]
pub struct PerfMetadata {
/// The version of this metadata format.
pub version: u64,

/// Name and version of the integration
pub integration: (String, String),

/// Per-pid modules that should be ignored, with runtime address ranges derived from symbol bounds + load bias
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub ignored_modules_by_pid: HashMap<pid_t, Vec<(String, u64, u64)>>,

/// Deduplicated debug info entries, keyed by semantic key
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub debug_info: HashMap<String, ModuleDebugInfo>,

/// Per-pid debug info references, mapping PID to mounted modules' debug info
/// Referenced by `path_keys` that point to the deduplicated `debug_info` entries.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub mapped_process_debug_info_by_pid: HashMap<pid_t, Vec<MappedProcessDebugInfo>>,

/// Per-pid unwind data references, mapping PID to mounted modules' unwind data
/// Referenced by `path_keys` that point to the deduplicated `unwind_data` files on disk.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub mapped_process_unwind_data_by_pid: HashMap<pid_t, Vec<MappedProcessUnwindData>>,

/// Per-pid symbol references, mapping PID to its mounted modules' symbols
/// Referenced by `path_keys` that point to the deduplicated `symbols.map` files on disk.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub mapped_process_module_symbols: HashMap<pid_t, Vec<MappedProcessModuleSymbols>>,

/// Mapping from semantic `path_key` to original binary path on host disk
/// Used by `mapped_process_debug_info_by_pid`, `mapped_process_unwind_data_by_pid` and
/// `mapped_process_module_symbols` the deduplicated entries
///
/// Until now, only kept for traceability, if we ever need to reconstruct the original paths from the keys
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub path_key_to_path: HashMap<String, PathBuf>,

// Deprecated fields below are kept for backward compatibility, since this struct is used in
// the parser and older versions of the runner still generate them
//
/// The URIs of the benchmarks with the timestamps they were executed at.
#[deprecated(note = "Use ExecutionTimestamps in the 'artifacts' module instead")]
pub uri_by_ts: Vec<(u64, String)>,

/// Modules that should be ignored and removed from the folded trace and callgraph (e.g. python interpreter)
#[deprecated(note = "Use 'ignored_modules_by_pid' instead")]
pub ignored_modules: Vec<(String, u64, u64)>,

/// Marker for certain regions in the profiling data
#[deprecated(note = "Use ExecutionTimestamps in the 'artifacts' module instead")]
pub markers: Vec<MarkerType>,

/// Debug info for all modules across all processes, mapping PID to module debug info
#[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")]
pub debug_info_by_pid: std::collections::HashMap<i32, Vec<ModuleDebugInfo>>,
/// Kept for backward compatibility, was used before deduplication of debug info entries.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
#[deprecated(note = "Use 'debug_info' + 'mapped_process_debug_info_by_pid' instead")]
pub debug_info_by_pid: HashMap<pid_t, Vec<ModuleDebugInfo>>,
}

impl PerfMetadata {
Expand Down
11 changes: 11 additions & 0 deletions crates/runner-shared/src/module_symbols.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use serde::{Deserialize, Serialize};

/// File suffix used when registering module symbols in a PID agnostic way.
pub const SYMBOLS_MAP_SUFFIX: &str = "symbols.map";

/// Per-pid mounting info referencing a deduplicated perf map entry.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MappedProcessModuleSymbols {
pub perf_map_key: String,
pub load_bias: u64,
}
Loading