Samply multiple perf events with samply#400
Conversation
…iler Set SAMPLY_PERF_EVENTS when wrapping the benchmark command with samply, so the profile carries per-sample hardware event deltas alongside the stack samples, mirroring the event capture the perf profiler does. Make PerfEvent's perf names architecture-aware: each variant is a semantic slot of the cache model, backed by the architected PMU events on arm64 (l1d_cache, l2d_cache, l2d_cache_refill, as before) and by the generalized cache events on x86_64 (L1-dcache-loads, L1-dcache-load-misses, cache-misses), where no combined L2 event is exposed. This also gives the perf profiler a working event set on x86_64, which previously disabled event sampling entirely. samply degrades gracefully to cycles-only sampling when the PMU can't deliver the events, so the env var is set unconditionally on Linux. Refs COD-2810 Co-Authored-By: Claude <noreply@anthropic.com>
Merging this PR will not alter performance
|
Greptile SummaryThis PR extends the samply profiler integration to capture multiple hardware perf events (CPU cycles, L1/L2 cache accesses, cache misses, instructions) alongside the default sampling event, using a new
Confidence Score: 4/5Core profiling changes are safe; the dev-workflow script has a bug that breaks reader sync but does not affect production builds. The samply profiler and perf_event changes are correct and well-tested. The only real defect is in the new developer script: reader_tracked_rev() greps for the wrong GitHub org (CodSpeedHQ instead of AvalancheHQ), so the reader checkout is silently skipped in both sync and recap. This is isolated to the dev script and has no impact on the compiled binary or CI, but it means the script doesn't fully work as documented from day one. scripts/samply-dev.sh — the reader_tracked_rev grep needle uses the wrong org name Important Files Changed
|
| #[test] | ||
| fn print_specs_for_this_host() { | ||
| for event in PerfEvent::all_events() { | ||
| println!("{event:?} -> {:?}", event.to_samply_spec()); | ||
| } | ||
| } |
There was a problem hiding this comment.
This test uses
println!, which is forbidden by the project style guide. Use a tracing macro (debug!, info!, etc.) instead — or, since its only purpose is human-readable debug output during manual inspection, it can reasonably be removed or replaced with a debug! call.
| #[test] | |
| fn print_specs_for_this_host() { | |
| for event in PerfEvent::all_events() { | |
| println!("{event:?} -> {:?}", event.to_samply_spec()); | |
| } | |
| } | |
| #[test] | |
| fn print_specs_for_this_host() { | |
| for event in PerfEvent::all_events() { | |
| eprintln!("{event:?} -> {:?}", event.to_samply_spec()); | |
| } | |
| } |
Rule Used: Never use println!/eprintln! in Rust; use trac... (source)
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!
| which = "8.0.2" | ||
| crc32fast = "1.5.0" | ||
| samply = { git = "https://github.com/CodSpeedHQ/samply-codspeed", rev = "ec97a70c0667098f8607f30a607ddd031a15a8b8" } | ||
| samply = { git = "https://github.com/CodSpeedHQ/samply-codspeed", rev = "81ba2c346e71" } |
There was a problem hiding this comment.
The
samply dep uses a 12-character abbreviated SHA (81ba2c346e71), while every other git-pinned dep in this file uses a full 40-character SHA. Short hashes can become ambiguous as a repo grows. The full hash from Cargo.lock is 81ba2c346e71d05aaef94448e2962961d29cb4c8.
| samply = { git = "https://github.com/CodSpeedHQ/samply-codspeed", rev = "81ba2c346e71" } | |
| samply = { git = "https://github.com/CodSpeedHQ/samply-codspeed", rev = "81ba2c346e71d05aaef94448e2962961d29cb4c8" } |
Rule Used: Pin Cargo git dependencies to tag or rev, neve... (source)
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!
Related: CodSpeedHQ/samply-codspeed#6 which adds support to provide extra perf events