Skip to content

Conversation

@albertxu216
Copy link

@albertxu216 albertxu216 commented Aug 13, 2025

bpf_task_state: a BPF-based tool for collecting and analyzing process state transitions, latency, memory usage, IO, and stack traces in Linux.
Features:

  • Collects per-process and system-wide state statistics (running, sleeping, etc.)
  • Supports filtering by PID and process name (comm), with wildcard and multi-process support
  • Tracks memory usage, read/write bytes, and page delay metrics (FreePages, Thrashing, SwapIn)
  • Outputs kernel and user stack traces for each process, with symbol resolution
  • Supports interval and event-driven sampling, latency threshold filtering, and per-instance statistics
  • Provides flame graph data for performance analysis

Usage examples:

  • Show all process state statistics every second: perf-prof bpf:task-state -i 1000
bpf_task_state -i
  • Filter by PID: perf-prof bpf:task-state -p 1234 -i 1000
bpf_task_state -p -i
  • Filter by process name (supports wildcards): perf-prof bpf:task-state --filter 'java,python*' -i 1000
bpf_task_state --filter -i
  • Only show events with latency greater than 20ms and print stack traces: perf-prof bpf:task-state --filter 'java,python*' -SD --than 20ms -g
bpf_task_state --filter -than -g
  • Output per-instance statistics with latency threshold: perf-prof bpf:task-state --perins --than 1ms -i 1000

bpf-pystack: Uses eBPF technology to maintain the call stacks of Python threads;
Clipboard_Screenshot_1755144356

  • Outputs them python-stacks with kernel and user call stacks at appropriate times;
  • Compared to pystack, bpf-pystack supports stack maintenance for newly created processes.

AlbertXu and others added 4 commits August 13, 2025 14:30
… state transitions, latency, memory usage, IO, and stack traces in Linux.

Features:
- Collects per-process and system-wide state statistics (running, sleeping, etc.)
- Supports filtering by PID and process name (comm), with wildcard and multi-process support
- Tracks memory usage, read/write bytes, and page delay metrics (FreePages, Thrashing, SwapIn)
- Outputs kernel and user stack traces for each process, with symbol resolution
- Supports interval and event-driven sampling, latency threshold filtering, and per-instance statistics
- Provides flame graph data for performance analysis

Usage examples:
- Show all process state statistics every second:
    perf-prof bpf:task-state -i 1000

- Filter by PID:
    perf-prof bpf:task-state -p 1234 -i 1000

- Filter by process name (supports wildcards):
    perf-prof bpf:task-state --filter 'java,python*' -i 1000

- Only show events with latency greater than 20ms and print stack traces:
    perf-prof bpf:task-state -p 1234 -SD --than 20ms -g

- Output per-instance statistics with latency threshold:
    perf-prof bpf:task-state --perins --than 1ms -i 1000
…on threads

outputs python call stacks together with kernel-stack and user-stacks at appropriate times.
Compared to pystack, bpf-pystack supports stack maintenance for newly created processes.

Usage examples:
--bpf-python-callchain <libpython_path> (--bpf-python-callchain /usr/local/lib/libpython3.6m.so.1.0)
…on threads

bpf-pystack: Uses eBPF technology to maintain the call stacks of Python threads
Outputs python-stack together with kernel and user call stacks at appropriate times. 
Compared to pystack, bpf-pystack supports stack maintenance for newly created processes.
@albertxu216 albertxu216 changed the title bpf_task_state: a BPF-based tool for collecting and analyzing process state transitions, latency, memory usage, IO, and stack traces in Linux. Add bpf_task_state and bpf_pystack Aug 14, 2025
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