Skip to content

feat(valgrind): declare the pid a benchmark ran in - #32

Open
lvaroqui wants to merge 2 commits into
mainfrom
cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation
Open

lvaroqui wants to merge 2 commits into
mainfrom
cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation

Conversation

@lvaroqui

@lvaroqui lvaroqui commented Oct 1, 2026 •

Copy link
Copy Markdown

Make the valgrind instrument use the pid argument of set_executed_benchmark, which it ignored until now.

When the pid differs from the calling process, the instrument registers a Benchmark pid: <pid> desc line just before the URI dump. It does this through the new CALLGRIND_ADD_DESC request from CodSpeedHQ/valgrind-codspeed#43, so the line lands in that benchmark's part header:

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

This lets a profile consumer tell a process that only launched the benchmark apart from the one that ran it. A launcher's own spawn-and-wait cost can then be left out.

The public API is unchanged. Benchmarks run in the calling process, which covers every integration today, get no extra line and no extra part. On a valgrind without the request, the call only logs a warning and the dump happens as before.

Notes for review:

Closes COD-3722

@lvaroqui
lvaroqui force-pushed the cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation branch 3 times, most recently from bceaeab to cf65ec8 Compare October 5, 2026 09:35
The valgrind instrument ignored the pid passed to set_executed_benchmark,
so a dump made by a process that only launched the benchmark looked the
same as one made by the process that ran it.

When the pid differs from the calling process, add a
"Benchmark pid: <pid>" desc line before the URI dump, through the new
CALLGRIND_ADD_DESC client request. A benchmark run in the calling
process gets no extra line. Valgrind builds without the request only log
a warning and dump as before.

Sync includes/callgrind.h with valgrind-codspeed and regenerate
dist/core.c.

Closes COD-3722
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lvaroqui added a commit that referenced this pull request Oct 5, 2026
@lvaroqui
lvaroqui force-pushed the cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation branch from cf65ec8 to 345c9d1 Compare October 5, 2026 09:42
@lvaroqui
lvaroqui marked this pull request as ready for review October 5, 2026 09:44
@lvaroqui
lvaroqui requested a review from not-matthias October 5, 2026 09:44
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Adds process ID tracking to benchmark profiling output.

The PR appears safe to merge, with a non-blocking gap in regression coverage for the new profile-header behavior.

Fix All in Claude CodeFindings

  1. P2 PID header lacks regression coverage ▶
Fix with agent prompt
### Issue 1
src/instruments/valgrind.zig:50-53
The new branch adds `Benchmark pid` to the Callgrind part header, but the existing Valgrind smoke test does not inspect a Callgrind profile, and the no-crash test checks only the return code. A missing or misplaced description could therefore pass CI, leaving profile consumers unable to distinguish launcher cost from benchmark cost. A test that inspects the dumped header would protect this behavior.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds a Callgrind client request that labels a dumped part with the benchmark PID when it differs from the reporting process, and regenerates the distributed C implementation.

  • Updates the Valgrind header, C wrapper, and Zig instrument while preserving the existing public API.
  • Switches the lint workflow to a pinned prek action.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["set_executed_benchmark(pid, URI)"] --> B{"pid differs from getpid()?"}
  B -- Yes --> C["Register Benchmark pid description"]
  B -- No --> D["Dump stats at URI"]
  C --> D
  D --> E["Callgrind part header and counters"]
Loading

Reviews (1) · Last reviewed commit: "ci: use prek instead of pre-commit (#32)"

Comment thread src/instruments/valgrind.zig Outdated
Comment thread .github/workflows/ci.yml
Comment thread src/instruments/valgrind.zig Outdated
lvaroqui added a commit that referenced this pull request Oct 5, 2026
@lvaroqui
lvaroqui force-pushed the cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation branch from 345c9d1 to b8bd763 Compare October 5, 2026 10:24
@lvaroqui
lvaroqui force-pushed the cod-3722-ignore-process-spawning-overhead-in-exec-harness-simulation branch from b8bd763 to bd2475c Compare October 5, 2026 10: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.

3 participants