1 unstable release
| 0.1.0 | Jul 26, 2025 |
|---|
#82 in Profiling
470KB
13K
SLoC
rjprof
(Rust-Java profiler), similar to async-profiler.
Quick Start
# Build everything
make build
# Quick test with Hello World
make run-hello
# Test with Spring Boot application (builds and runs automatically)
make run-spring
# Profile your own JAR
make profile JAR=myapp.jar ARGS="--spring --mode user"
Project Structure
This project uses a Cargo workspace with two main components:
librjprof/- Core profiling library using JVMTIrjprof-cli/- Command-line interface and toolsexamples/- Sample applications for testing
Building
Simple Build (Recommended)
make build # Release build
make dev # Debug build (faster)
make install # Build and copy binaries to bin/
Manual Build
cargo build --release --workspace
Requirements
- Rust (latest stable)
- Java Development Kit (JDK 8+) with
JAVA_HOMEset - Maven (for Spring demo)
- Optional: flamegraph.pl or inferno-flamegraph for SVG generation
🔧 Usage
Basic Profiling
# Profile any JAR file
./target/release/rjprof --jar myapp.jar
# Profile with Spring filtering (removes framework noise)
./target/release/rjprof --jar myapp.jar --spring
# Focus on user code only
./target/release/rjprof --jar myapp.jar --mode user
# Filter by performance thresholds
./target/release/rjprof --jar myapp.jar --min-pct 0.5 --min-total 1ms
Advanced Options
# Custom package filtering
./target/release/rjprof --jar myapp.jar --exclude "java.*,org.apache.*" --include "com.mycompany.*"
# Different sorting and output options
./target/release/rjprof --jar myapp.jar --sort total --export json --no-color
# Verbose output with flamegraph generation
./target/release/rjprof --jar myapp.jar --verbose --generate-flamegraph
Profile Modes
all- Profile everything (can be noisy)user- Focus on user code, exclude JDK/framework (default)hotspots- Only methods above performance thresholdsallocation- Focus on allocation-heavy methods
Makefile Targets
| Target | Description |
|---|---|
make build |
Build release version |
make dev |
Build debug version (faster) |
make test |
Run all tests |
make run-hello |
Quick test with Hello World |
make run-spring |
Test with Spring Boot demo |
make flamegraph |
Generate SVG from last run |
make clean |
Clean build artifacts |
make help |
Show all available targets |
📊 Features
Smart Filtering
- Spring Boot optimized - Automatically filters common Spring/framework noise
- Custom package filtering - Include/exclude specific packages
- Performance thresholds - Hide methods below time/percentage limits
- Profile modes - Focus on different aspects of performance
Output Formats
- Colorized console output - Easy-to-read performance reports
- JSON export - Machine-readable data
- CSV export - Spreadsheet-compatible format
- Flamegraph generation - Visual performance analysis
Advanced Profiling
- Method entry/exit timing - Precise performance measurement
- Memory allocation tracking - Find allocation hotspots
- Call graph analysis - Understand call relationships
- Sampling support - Low-overhead profiling option
Examples
Profile Spring Boot Application
# Automatic: builds Spring demo and profiles it
make run-spring
# Manual: profile existing Spring JAR
./target/release/rjprof \
--jar myspring.jar \
--spring \
--mode user \
--min-pct 0.1 \
--sort self \
--generate-flamegraph
Custom Filtering for Microservice
./target/release/rjprof \
--jar microservice.jar \
--exclude "java.*,javax.*,org.springframework.*,org.apache.*" \
--include "com.mycompany.*" \
--mode hotspots \
--min-total 5ms \
--export json
Memory Allocation Analysis
./target/release/rjprof \
--jar myapp.jar \
--mode allocation \
--sort calls \
--min-self-time 100us
Flamegraph Generation
Generate visual flamegraphs for performance analysis:
# Run profiler with flamegraph generation
./target/release/rjprof --jar myapp.jar --generate-flamegraph
# Or generate from existing data
make flamegraph
Flamegraphs are saved to profiler_output/flamegraph.svg.
Development
Running Tests
make test # Run all tests
cargo test --workspace # Manual test execution
Code Quality
make check # Check code without building
cargo clippy --workspace # Run linter
cargo fmt --workspace # Format code
Performance Tips
- Use
--mode userfor most applications to focus on your code - Enable
--springfor Spring Boot apps to reduce noise - Set thresholds with
--min-pctand--min-totalto hide trivial methods - Generate flamegraphs for visual analysis of performance bottlenecks
- Export to JSON for integration with other analysis tools
Troubleshooting
Agent Not Found
# Manually specify agent path
./target/release/rjprof --jar myapp.jar --agent-path ./target/release/librjprof.dylib
JAVA_HOME Issues
# Ensure JAVA_HOME is set correctly
export JAVA_HOME=$(/usr/libexec/java_home) # macOS
export JAVA_HOME=/usr/lib/jvm/default # Linux
Build Issues
# Clean and rebuild
make clean
make build
# Check dependencies
cargo check --workspace
License
Licensed under either of:
- Apache License, Version 2.0
- MIT License
Dependencies
~5–18MB
~190K SLoC