|
1 | 1 | use anyhow::Context; |
| 2 | +use libc::pid_t; |
2 | 3 | use serde::{Deserialize, Serialize}; |
| 4 | +use std::collections::HashMap; |
3 | 5 | use std::io::BufWriter; |
4 | 6 | use std::path::Path; |
| 7 | +use std::path::PathBuf; |
5 | 8 |
|
6 | | -use crate::debug_info::ModuleDebugInfo; |
| 9 | +use crate::debug_info::{MappedProcessDebugInfo, ModuleDebugInfo}; |
7 | 10 | use crate::fifo::MarkerType; |
| 11 | +use crate::module_symbols::MappedProcessModuleSymbols; |
| 12 | +use crate::unwind_data::MappedProcessUnwindData; |
8 | 13 |
|
9 | | -#[derive(Serialize, Deserialize)] |
| 14 | +#[derive(Serialize, Deserialize, Default)] |
10 | 15 | pub struct PerfMetadata { |
11 | 16 | /// The version of this metadata format. |
12 | 17 | pub version: u64, |
13 | 18 |
|
14 | 19 | /// Name and version of the integration |
15 | 20 | pub integration: (String, String), |
16 | 21 |
|
| 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 | + // |
17 | 56 | /// The URIs of the benchmarks with the timestamps they were executed at. |
18 | 57 | #[deprecated(note = "Use ExecutionTimestamps in the 'artifacts' module instead")] |
19 | 58 | pub uri_by_ts: Vec<(u64, String)>, |
20 | 59 |
|
21 | 60 | /// 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")] |
22 | 62 | pub ignored_modules: Vec<(String, u64, u64)>, |
23 | 63 |
|
24 | 64 | /// Marker for certain regions in the profiling data |
25 | 65 | #[deprecated(note = "Use ExecutionTimestamps in the 'artifacts' module instead")] |
26 | 66 | pub markers: Vec<MarkerType>, |
27 | 67 |
|
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>>, |
31 | 72 | } |
32 | 73 |
|
33 | 74 | impl PerfMetadata { |
|
0 commit comments