中文文档 | English
🔥 A high-performance Golang application profiling tool based on eBPF technology, capable of generating interactive flame graphs for performance analysis.
- 🚀 Zero-overhead profiling: Uses eBPF technology for minimal performance impact
- 🎯 Precise stack tracing: Captures complete call stacks with symbol resolution
- 🔥 Interactive flame graphs: Generates SVG flame graphs with zoom and search capabilities
- 🎨 Customizable visualization: Supports various color schemes and layout options
- 📊 Multiple output formats: SVG flame graphs and folded stack traces
- 🔧 Flexible targeting: Profile by PID, process name, or system-wide
- ⚡ Real-time analysis: Live profiling with configurable sampling rates
- Operating System: Linux (kernel version >= 4.4)
- Architecture: x86_64, aarch64
- Privileges: Root access or CAP_BPF capability
- Dependencies:
- Rust toolchain (>= 1.70)
- LLVM/Clang (>= 10.0)
- Linux headers
- Perl (for flame graph generation)
Download the latest release from GitHub Releases:
# Download for x86_64 Linux
wget https://github.com/YOUR_USERNAME/golang-profile/releases/latest/download/golang-profiling-linux-x86_64.tar.gz
tar -xzf golang-profiling-linux-x86_64.tar.gz
sudo mv golang-profiling /usr/local/bin/
# Download for ARM64 Linux
wget https://github.com/YOUR_USERNAME/golang-profile/releases/latest/download/golang-profiling-linux-aarch64.tar.gz
tar -xzf golang-profiling-linux-aarch64.tar.gz
sudo mv golang-profiling /usr/local/bin/curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/envUbuntu/Debian:
sudo apt update
sudo apt install -y clang llvm libelf-dev libz-dev pkg-config linux-headers-$(uname -r) perlCentOS/RHEL/Fedora:
# CentOS/RHEL
sudo yum install -y clang llvm elfutils-libelf-devel zlib-devel pkgconfig kernel-headers perl
# Fedora
sudo dnf install -y clang llvm elfutils-libelf-devel zlib-devel pkgconfig kernel-headers perlArch Linux:
sudo pacman -S clang llvm libelf zlib pkgconf linux-headers perlcargo install bpf-linkergit clone <repository-url>
cd golang-profile
cargo build --releaseThe compiled binary will be available at target/release/golang-profiling.
# Profile by PID
sudo ./target/release/golang-profiling --pid 1234 --duration 10 --output profile.svg
# Profile by process name
sudo ./target/release/golang-profiling --name "my-go-app" --duration 30 --output app_profile.svg
# System-wide profiling
sudo ./target/release/golang-profiling --duration 5 --output system_profile.svg| Parameter | Description | Default | Example |
|---|---|---|---|
--pid |
Target process PID | - | --pid 1234 |
--name |
Target process name | - | --name "golang-app" |
--duration |
Profiling duration (seconds) | 10 | --duration 30 |
--frequency |
Sampling frequency (Hz) | 99 | --frequency 199 |
--output |
Output SVG file path | flamegraph.svg |
--output profile.svg |
--folded-output |
Output folded stack file | - | --folded-output stacks.folded |
| Parameter | Description | Default | Example |
|---|---|---|---|
--title |
Flame graph title | "Flame Graph" | --title "My App Profile" |
--subtitle |
Flame graph subtitle | - | --subtitle "CPU Profile" |
--colors |
Color scheme | hot |
--colors java |
--bgcolors |
Background colors | - | --bgcolors blue |
--width |
Image width | 1200 | --width 1600 |
--height |
Row height | 16 | --height 20 |
--fonttype |
Font family | Verdana |
--fonttype Arial |
--fontsize |
Font size | 12 | --fontsize 14 |
--inverted |
Invert flame graph | false | --inverted |
--flamechart |
Generate flame chart | false | --flamechart |
--hash |
Consistent colors | false | --hash |
--random |
Random colors | false | --random |
sudo ./target/release/golang-profiling --pid 1234 --duration 10 --output basic_profile.svgsudo ./target/release/golang-profiling --name "my-service" --frequency 199 --duration 30 --output detailed_profile.svgsudo ./target/release/golang-profiling \
--pid 1234 \
--duration 15 \
--title "Production Service Profile" \
--subtitle "CPU Usage Analysis" \
--colors java \
--width 1600 \
--height 20 \
--fontsize 14 \
--output custom_profile.svgsudo ./target/release/golang-profiling --pid 1234 --inverted --title "Icicle Graph" --output icicle.svgsudo ./target/release/golang-profiling \
--pid 1234 \
--duration 20 \
--output profile.svg \
--folded-output profile.folded- SVG Flame Graph: Interactive flame graph that can be opened in browsers, supports click-to-zoom and search
- Folded Stack File: Text format raw data that can be used with other analysis tools
-
Choose Appropriate Sampling Frequency:
- High frequency (199Hz+): Suitable for short-term precise analysis
- Low frequency (49Hz-99Hz): Suitable for long-term monitoring
-
Recommended Duration:
- Development environment: 5-10 seconds
- Production environment: 30-60 seconds
-
Reading Flame Graphs:
- X-axis: Functions sorted alphabetically (not time)
- Y-axis: Call stack depth
- Width: Proportion of CPU time consumed by function
-
Permission Denied
Error: Permission deniedSolution: Run with
sudoor ensure user has CAP_BPF capability -
Process Not Found
Error: Process not foundSolution: Check if the process PID or name is correct
-
eBPF Not Supported
Error: BPF program load failedSolution: Ensure kernel version >= 4.4 and eBPF support is enabled
-
Missing Dependencies
Error: flamegraph.pl not foundSolution: Ensure Perl is installed and flamegraph.pl is in the project directory
This project is licensed under multiple licenses:
- Apache License 2.0
- MIT License
- GPL v2 License
Contributions are welcome! Please feel free to submit Issues and Pull Requests.
- FlameGraph - Brendan Gregg's flame graph tools
- aya - Rust eBPF library
Happy Profiling! 🔥