Skip to content

feat(exec-harness): declare the benchmarked command's pid - #559

Draft
lvaroqui wants to merge 2 commits into
spike/cod-3440-memtrack-muslfrom
cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation
Draft

lvaroqui wants to merge 2 commits into
spike/cod-3440-memtrack-muslfrom
cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation

Conversation

@lvaroqui

@lvaroqui lvaroqui commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Make exec-harness declare the pid of the command it benchmarks, so its own spawning cost can be left out of simulation results.

Since #531, exec-harness turns instrumentation on in its own process and spawns the command, which inherits that state across fork and exec. The dumped part therefore also holds the harness's cost of spawning the command and waiting for it. That is a fixed overhead on every benchmark, about 207k instructions per command locally.

Changes:

  • instrument-hooks binding: new set_executed_benchmark_for_pid(pid, uri). set_executed_benchmark keeps its behavior and delegates to it.
  • exec-harness: spawns the command and passes its pid, instead of calling Command::status(). In memory mode the pid only travels to the runner's FIFO, where nothing reads it for exec-harness.
  • Submodule bump: feat(valgrind): declare the pid a benchmark ran in instrument-hooks#32 writes desc: Benchmark pid: <pid> in the part when the pid is not the caller's. This bump also brings the thread-safe C API exports and the callgrind_toggle_collect helper.

Checked locally under the patched valgrind, with the runner's simulation flags on sh -c '/bin/true; /bin/true; :':

part: 2
desc: Spawned pid: 289126
desc: Benchmark pid: 289126
desc: Trigger: Client Request: exec_harness::true_twice

Still to do before this is ready:

Closes COD-3722

@codspeed

codspeed Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation (3c1b378) with spike/cod-3440-memtrack-musl (ef0764f)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@lvaroqui
lvaroqui force-pushed the cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation branch from 485598a to f676ede Compare October 5, 2026 10:49
lvaroqui and others added 2 commits October 5, 2026 15:24
Add set_executed_benchmark_for_pid, which passes an explicit pid to
instrument_hooks_set_executed_benchmark instead of the calling process'
own. set_executed_benchmark keeps its behavior and delegates to it.

Bump instrument-hooks, whose valgrind instrument now writes a
"Benchmark pid: <pid>" desc line in the dump part when that pid is not
the calling process'. This also brings thread-safe C API exports and the
callgrind_toggle_collect helper.

Refs COD-3722
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The memory executor grants file capabilities to the runner's executable,
and valgrind refuses to run an executable that carries them. A simulation
run of an exec target then failed with "Permission denied" (exit code
126) as soon as the executable had been granted them, since exec-harness
runs through it.

Pass --allow-file-caps with the runner's executable path, so valgrind
runs it without the capabilities, which its internal subcommands do not
need. This option requires a valgrind-codspeed build that supports it.

Refs COD-3722
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lvaroqui
lvaroqui force-pushed the cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation branch from c72e991 to 3c1b378 Compare October 5, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant