Skip to content

feat(presto/slurm): kernel perf flamegraph profiling pipeline - #394

Draft
misiugodfrey wants to merge 1 commit into
mainfrom
misiug/bench-perf-profiling
Draft

feat(presto/slurm): kernel perf flamegraph profiling pipeline#394
misiugodfrey wants to merge 1 commit into
mainfrom
misiug/bench-perf-profiling

Conversation

@misiugodfrey

Copy link
Copy Markdown
Contributor

Summary

Adds a self-contained CPU-time profiling pipeline using Linux kernel perf, with no Perl or CDN dependencies for flamegraph rendering. The pipeline is query-bounded (attach after workers are ready, stop after the query of interest), sharded across TIDs to keep per-worker file sizes manageable, and deferred for symbolization to avoid impact during the benchmark.

Based on kjmph's bench33 POC patch.

New files

  • perf_flamegraph.py: dependency-free SVG flamegraph renderer written in Python stdlib; reads perf script text output and writes a single self-contained HTML/SVG file; no FlameGraph.pl, no CDN, no Node.js
  • perf_profiler_functions.sh: coordinator-side enable/stop token handshake using filesystem sentinel files; the benchmark loop writes an enable token before each query and a stop token after; the sampler uses these to bound its capture window
  • perf-record-sharded.sh: divides the worker's thread list into N shards and runs one perf record process per shard; keeps per-shard perf.data files below a configurable size ceiling
  • perf-worker-sampler.sh: host-side orchestration; waits for the enable token, attaches to the worker process, records until the stop token, publishes capture files to the result directory; includes preflight checks for perf_event_paranoid and debug symbol availability
  • process-perf-captures.sh: deferred post-processing script run from the login node after the job completes; calls perf script for symbolization and perf_flamegraph.py for rendering; designed to run after job exit so symbolization doesn't interfere with benchmark timing
  • presto-repl-from-job.sh: launches an interactive Presto CLI session connected to a running job's coordinator using srun --overlap; useful for inspecting retained query state during a live benchmark

Integration hooks

  • functions.sh: run_worker launches perf-worker-sampler.sh as a sidecar srun step when ENABLE_PERF=1
  • launch-run.sh: --perf, --perf-output-dir, --perf-frequency flags
  • run-presto-benchmarks.sh: ENABLE_PERF propagation and result dir integration

Dependencies

Verification

  • Run a GPU benchmark with --perf on the NVL72 cluster; verify perf-worker-sampler.sh attaches to worker processes and produces perf.data.* shard files in result_dir_<jobid>/perf/
  • Verify the enable/stop token handshake bounds the capture window to a single query (not the full job duration)
  • Run process-perf-captures.sh on the result directory after the job; verify it produces flamegraph.svg (or .html) for each captured worker
  • Open the rendered flamegraph in a browser and confirm the SVG is interactive (hover, click-to-zoom)
  • Run presto-repl-from-job.sh <job_id> against a live benchmark; verify the Presto CLI connects and can execute queries
  • Verify perf-record-sharded.sh splits the TID list correctly and each shard produces a separate perf.data.<n> file
  • Run ./ci/check_style.sh on changed Python and shell files

@copy-pr-bot

copy-pr-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@misiugodfrey
misiugodfrey force-pushed the misiug/bench-perf-profiling branch from 1160024 to 15e43c7 Compare July 27, 2026 22:05
Based on kjmph's bench33 POC patch.

Adds a fully self-contained CPU-time profiling pipeline using Linux
kernel perf, with no Perl or CDN dependencies for flamegraph rendering.

New scripts:
- perf_flamegraph.py: dependency-free SVG flamegraph renderer; reads
  perf script output and writes a single self-contained HTML/SVG file
- perf_profiler_functions.sh: coordinator-side enable/stop token
  handshake (filesystem sentinel files for query-bounded profiling)
- perf-record-sharded.sh: bounded TID-shard perf record processes;
  each shard captures a subset of worker TIDs to keep file sizes
  manageable on multi-threaded workers
- perf-worker-sampler.sh: host-side orchestration; preflight checks,
  perf attach after workers are live, token-gated stop, publish
- process-perf-captures.sh: deferred symbolization and flamegraph
  rendering; runs from the login node after the job completes
- presto-repl-from-job.sh: launch an interactive Presto CLI session
  connected to a coordinator from a running Slurm job

Integration hooks:
- functions.sh: perf sidecar launch in run_worker
- launch-run.sh: --perf, --perf-output-dir, --perf-frequency flags
- run-presto-benchmarks.sh: ENABLE_PERF propagation and result dir
  integration
@misiugodfrey
misiugodfrey force-pushed the misiug/bench-perf-profiling branch from 15e43c7 to fd26f8b Compare July 28, 2026 16:03
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