Skip to content

feat: add samply profiler support#338

Merged
not-matthias merged 17 commits into
mainfrom
cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format
May 12, 2026
Merged

feat: add samply profiler support#338
not-matthias merged 17 commits into
mainfrom
cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format

Conversation

@not-matthias
Copy link
Copy Markdown
Member

No description provided.

@not-matthias not-matthias force-pushed the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch from 468b6c8 to 0e6e4ea Compare May 5, 2026 14:16
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 5, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 7 untouched benchmarks


Comparing cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format (d32d356) with main (58520c3)

Open in CodSpeed

@not-matthias not-matthias force-pushed the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch 3 times, most recently from b55c9b2 to 9a2ab1b Compare May 7, 2026 13:37
Copy link
Copy Markdown
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to github mid review, have to publish 😬

Comment thread src/executor/wall_time/profiler/mod.rs Outdated
Comment thread src/executor/wall_time/perf/mod.rs Outdated
Copy link
Copy Markdown
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass done, let me know if you want to sync on some points

Comment thread src/executor/wall_time/profiler/perf/mod.rs
Comment thread src/executor/wall_time/executor.rs
Comment thread src/executor/wall_time/executor.rs
Comment thread src/executor/wall_time/executor.rs Outdated
Comment thread src/cli/shared.rs Outdated
Comment thread src/executor/wall_time/profiler/samply/mod.rs Outdated
Comment thread src/executor/wall_time/profiler/samply/mod.rs Outdated
Comment thread src/cli/mod.rs
Comment thread src/executor/wall_time/profiler/samply/mod.rs Outdated
Comment thread src/cli/samply.rs
@not-matthias not-matthias force-pushed the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch 3 times, most recently from 021df91 to 0fdb0de Compare May 8, 2026 14:36
@not-matthias not-matthias force-pushed the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch 3 times, most recently from dd3a1e3 to c7f0146 Compare May 8, 2026 16:52
Copy link
Copy Markdown
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

olgtm

Comment thread .github/workflows/ci.yml
Comment thread src/executor/helpers/env.rs Outdated
Comment thread src/executor/shared/fifo.rs Outdated
@not-matthias not-matthias force-pushed the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch from 95fba72 to 2267530 Compare May 12, 2026 19:42
Relocate src/executor/wall_time/perf/ to src/executor/wall_time/profiler/perf/
in preparation for additional profiler backends (samply).
Output filename also changes from perf.metadata to walltime.metadata.
This is a wire-breaking change that requires a coordinated server
rollout to read the new filename.
PerfRunner becomes PerfProfiler implementing the Profiler trait. The
RunnerFifo loop moves out of the perf module and into WallTimeExecutor,
which now drives the trait callbacks (on_start_benchmark / on_stop_benchmark
/ on_ping / GetIntegrationMode) generically.

Profiler::wrap stashes the perf control fifo and output path on the
profiler instance; finalize harvests the perf.data artifacts and writes
walltime.metadata. The OnceCell<BenchmarkData> bridge is gone — fifo
data and timestamps are passed directly into finalize.

Executor::run now takes &mut self to allow profilers to hold per-run
state on the trait object. This cascades through run_executor,
orchestrator, and the Memory/Valgrind executors (no behavioral
change for those — they don't mutate self).
…BLED

Introduce --enable-profiler / CODSPEED_PROFILER_ENABLED as the canonical
flag now that walltime profiling is profiler-agnostic. The legacy
--enable-perf / CODSPEED_PERF_ENABLED is kept as a hidden alias and
emits a deprecation warning when used, so existing configurations keep
working.
Tokio's OpenOptions::read_write is Linux-only, but the O_RDWR trick
works on every Unix and is required on macOS to avoid open() deadlocks
when both FIFO ends are opened before the peer process is spawned.
Mirror the clock used elsewhere in CodSpeed on macOS (mach_absolute_time
with cached mach_timebase_info) so runner and benchmark process
timestamps come from the exact same source. Adds mach2 as a macOS-only
dependency.
Move the Linux profiling sysctl setup out of the perf profiler and into a shared walltime profiler helper. This lets both perf and samply prepare kernel symbol access and non-root profiling consistently while preserving the existing sudo-based behavior.
Use the samply crate directly instead of a standalone binary. Adds a
`codspeed samply` subcommand that forwards args to samply's CLI and
dispatches to `do_record_action`. The wall_time profiler re-execs the
current binary, removing the need for a PATH-installed samply.
Enabling perf JIT support on macOS produces many unresolved
addresses in stack traces. Force it off until we understand why.
Rename `StartBenchmark`/`StopBenchmark` to `StartProfiler`/`StopProfiler`
and `BenchmarkStart`/`BenchmarkEnd` markers to `RoundStart`/`RoundEnd` to
match the profiler-agnostic data format.
samply requires task_for_pid privileges that GitHub's macOS runners
don't grant, causing "Could not obtain the root task". The job only
exercises the walltime executor plumbing, so run it with
CODSPEED_PROFILER_ENABLED=false.
…command_builder

Each InternalCommands variant now owns how it's re-invoked: the
current_exe() resolution, CommandBuilder construction, and argv
layout all live in one place. The samply call site collapses from
hand-rolled CommandBuilder setup to a single chained expression.
@not-matthias not-matthias force-pushed the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch from 2267530 to d32d356 Compare May 12, 2026 20:00
@not-matthias not-matthias merged commit d32d356 into main May 12, 2026
21 checks passed
@not-matthias not-matthias deleted the cod-2599-runner-migrate-perf-to-new-profiler-agnostic-data-format branch May 12, 2026 21:22
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.

2 participants