Skip to content

Commit c87b3d9

Browse files
authored
fix(runner-shared): always set PYTHONPERFSUPPORT (#577)
The runtime env only set PYTHONPERFSUPPORT=1 in memory mode. Since exec-harness 1.4.0 relies on that env, Python exec targets in simulation mode write no /tmp/perf-<pid>.map, and valgrind callgraphs lose every Python frame. exec-harness 1.3.0 set it per command in simulation mode. Set it in every mode. In walltime, PYTHON_PERF_JIT_SUPPORT=1 takes precedence in CPython, so Linux still uses jitdump. On macOS walltime, where jitdump stays off, Python now emits the perf map. The perf trampoline adds instructions: a Python exec benchmark measured under callgrind goes from 2.22e9 to 2.51e9 Ir (+13%), back to the 1.3.0 level. Closes COD-3820
1 parent 24f182e commit c87b3d9

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

  • crates/runner-shared/src/runtime_env

‎crates/runner-shared/src/runtime_env/python.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ const PYTHONPERFSUPPORT: &str = "PYTHONPERFSUPPORT";
99
/// - `PYTHON_PERF_JIT_SUPPORT`: perf jitdump for walltime profiles.
1010
/// FIXME(COD-2645): Keep this disabled on macOS. Enabling it causes
1111
/// many unresolved addresses on the stack when profiling with samply.
12-
/// - `PYTHONPERFSUPPORT=1`: `/tmp/perf-<pid>.map` so memory flamegraphs can name Python frames.
12+
/// - `PYTHONPERFSUPPORT=1`: `/tmp/perf-<pid>.map` so valgrind and memory flamegraphs can
13+
/// name Python frames. When `PYTHON_PERF_JIT_SUPPORT=1` is also set, CPython uses jitdump.
1314
pub(super) fn env(mode: MeasurementMode) -> Vec<(&'static str, String)> {
1415
let perf_jit = mode == MeasurementMode::Walltime && !cfg!(target_os = "macos");
1516
let perf_jit_value = if perf_jit { "1" } else { "0" };
16-
let mut env = vec![
17+
vec![
1718
(PYTHONHASHSEED, "0".to_owned()),
1819
(PYTHON_PERF_JIT_SUPPORT, perf_jit_value.to_owned()),
19-
];
20-
if mode == MeasurementMode::Memory {
21-
env.push((PYTHONPERFSUPPORT, "1".to_owned()));
22-
}
23-
env
20+
(PYTHONPERFSUPPORT, "1".to_owned()),
21+
]
2422
}

0 commit comments

Comments
 (0)