Skip to content

Commit 5bb49e6

Browse files
feat(runner-shared): add new fields to perf metadata
Only declare them to allow deploying the backend in a backwards compatible manner.
1 parent ad6011b commit 5bb49e6

8 files changed

Lines changed: 311 additions & 49 deletions

File tree

crates/runner-shared/src/debug_info.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ impl std::fmt::Debug for DebugInfo {
2121
}
2222
}
2323

24+
/// Per-pid mounting info referencing a deduplicated debug info entry.
25+
#[derive(Serialize, Deserialize, Clone, Debug)]
26+
pub struct MappedProcessDebugInfo {
27+
pub debug_info_key: String,
28+
pub load_bias: u64,
29+
}
30+
2431
#[derive(Debug, Clone, Serialize, Deserialize)]
2532
pub struct ModuleDebugInfo {
2633
/// The path to the object file on disk (e.g. `/usr/lib/libc.so.6`)

crates/runner-shared/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub mod artifacts;
22
pub mod debug_info;
33
pub mod fifo;
44
pub mod metadata;
5+
pub mod module_symbols;
56
pub mod perf_event;
67
pub mod unwind_data;
78
pub mod walltime_results;

crates/runner-shared/src/metadata.rs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,74 @@
11
use anyhow::Context;
2+
use libc::pid_t;
23
use serde::{Deserialize, Serialize};
4+
use std::collections::HashMap;
35
use std::io::BufWriter;
46
use std::path::Path;
7+
use std::path::PathBuf;
58

6-
use crate::debug_info::ModuleDebugInfo;
9+
use crate::debug_info::{MappedProcessDebugInfo, ModuleDebugInfo};
710
use crate::fifo::MarkerType;
11+
use crate::module_symbols::MappedProcessModuleSymbols;
12+
use crate::unwind_data::MappedProcessUnwindData;
813

9-
#[derive(Serialize, Deserialize)]
14+
#[derive(Serialize, Deserialize, Default)]
1015
pub struct PerfMetadata {
1116
/// The version of this metadata format.
1217
pub version: u64,
1318

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

22+
/// Per-pid modules that should be ignored, with runtime address ranges derived from symbol bounds + load bias
23+
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
24+
pub ignored_modules_by_pid: HashMap<pid_t, Vec<(String, u64, u64)>>,
25+
26+
/// Deduplicated debug info entries, keyed by semantic key
27+
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
28+
pub debug_info: HashMap<String, ModuleDebugInfo>,
29+
30+
/// Per-pid debug info references, mapping PID to mounted modules' debug info
31+
/// Referenced by `path_keys` that point to the deduplicated `debug_info` entries.
32+
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
33+
pub mapped_process_debug_info_by_pid: HashMap<pid_t, Vec<MappedProcessDebugInfo>>,
34+
35+
/// Per-pid unwind data references, mapping PID to mounted modules' unwind data
36+
/// Referenced by `path_keys` that point to the deduplicated `unwind_data` files on disk.
37+
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
38+
pub mapped_process_unwind_data_by_pid: HashMap<pid_t, Vec<MappedProcessUnwindData>>,
39+
40+
/// Per-pid symbol references, mapping PID to its mounted modules' symbols
41+
/// Referenced by `path_keys` that point to the deduplicated `symbols.map` files on disk.
42+
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
43+
pub mapped_process_module_symbols: HashMap<pid_t, Vec<MappedProcessModuleSymbols>>,
44+
45+
/// Mapping from semantic `path_key` to original binary path on host disk
46+
/// Used by `mapped_process_debug_info_by_pid`, `mapped_process_unwind_data_by_pid` and
47+
/// `mapped_process_module_symbols` the deduplicated entries
48+
///
49+
/// Until now, only kept for traceability, if we ever need to reconstruct the original paths from the keys
50+
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
51+
pub path_key_to_path: HashMap<String, PathBuf>,
52+
53+
// Deprecated fields below are kept for backward compatibility, since this struct is used in
54+
// the parser and older versions of the runner still generate them
55+
//
1756
/// The URIs of the benchmarks with the timestamps they were executed at.
1857
#[deprecated(note = "Use ExecutionTimestamps in the 'artifacts' module instead")]
1958
pub uri_by_ts: Vec<(u64, String)>,
2059

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

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

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

3374
impl PerfMetadata {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// File suffix used when registering module symbols in a PID agnostic way.
4+
pub const SYMBOLS_MAP_SUFFIX: &str = "symbols.map";
5+
6+
/// Per-pid mounting info referencing a deduplicated perf map entry.
7+
#[derive(Serialize, Deserialize, Clone, Debug)]
8+
pub struct MappedProcessModuleSymbols {
9+
pub perf_map_key: String,
10+
pub load_bias: u64,
11+
}

0 commit comments

Comments
 (0)