Skip to content

Improve flamegraph profiling: deeper stacks, off-CPU, better CSV#173

Merged
vadv merged 3 commits intomasterfrom
improve-flamegraph-profiling
Apr 5, 2026
Merged

Improve flamegraph profiling: deeper stacks, off-CPU, better CSV#173
vadv merged 3 commits intomasterfrom
improve-flamegraph-profiling

Conversation

@vadv
Copy link
Copy Markdown
Collaborator

@vadv vadv commented Apr 5, 2026

Summary

  • Use dwarf,16384 stack dump size for complete tokio async call stacks (default 8192 truncates deep stacks)
  • Add FLAMEGRAPH_OFFCPU=1 mode — generates blue flamegraph showing where pg_doorman waits (locks, pool contention, I/O) via offcputime-bpfcc
  • Generate profile.csv with both self and inclusive cost per function, plus summary.csv with CPU breakdown by category (pg_doorman, tokio, allocator, kernel_tcp, kernel_nftables, etc.)

Usage

# Standard CPU flamegraph
make flamegraph

# With off-CPU analysis
FLAMEGRAPH_OFFCPU=1 make flamegraph

New artifacts

flamegraph-output/<timestamp>/
├── profile.csv              # function,self_samples,self_pct,inclusive_samples,inclusive_pct,category
├── summary.csv              # category,self_samples,self_pct
├── flamegraph-offcpu.svg    # (only with FLAMEGRAPH_OFFCPU=1)
└── ...existing artifacts...

Test plan

  • make flamegraph produces all artifacts including new CSVs
  • profile.csv has correct inclusive cost (entry_SYSCALL at 72%, pg_doorman::handle at 63%)
  • summary.csv shows meaningful category breakdown
  • Cleanup works, no zombie processes
  • FLAMEGRAPH_OFFCPU=1 make flamegraph with bcc-tools installed

dmitrivasilyev added 3 commits April 5, 2026 11:23
- Use dwarf,16384 stack dump size instead of default 8192
  to capture complete async call stacks in tokio
- Add FLAMEGRAPH_OFFCPU=1 mode using offcputime-bpfcc to show
  where pg_doorman waits (locks, pool, I/O) as a blue flamegraph
- Generate profile.csv with both self and inclusive cost per function,
  plus summary.csv with CPU breakdown by category
- Use /usr/share/bcc/tools/offcputime path (Fedora puts bcc tools
  outside PATH), with fallback to offcputime-bpfcc and PATH lookup
- Clean offcputime output before passing to inferno: strip user/kernel
  separator '-' and [unknown] frames
- Pass file argument to inferno-flamegraph instead of stdin pipe
  (inferno fails with "No such file" when reading from pipe)
@vadv vadv merged commit 0943045 into master Apr 5, 2026
43 checks passed
@vadv vadv deleted the improve-flamegraph-profiling branch April 5, 2026 15:19
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