agentleFS
lodetomasilodetomasi/claude-code-skills-tools/.claude/skills/java-profiler/SKILL.md

java-profiler

Skill0 starsChanged 13 months agoMITView on GitHub

Enterprise Java profiling for JVM applications, microservices, and distributed systems

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Profile Realistic Workloads: Use production-like data volumes

    line 158
  2. Distinctive:

    Profile: Run YourKit/JProfiler during load test

    line 178

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Java Profiler Skill

Overview

Professional Java profiling skill integrating industry-leading tools for JVM performance analysis, memory management, and thread debugging in enterprise environments.

Capabilities

1. JVM Performance Analysis

  • YourKit Java Profiler: Deep profiling for distributed systems
  • JProfiler: Advanced UI with real-time metrics
  • VisualVM: Built-in monitoring and profiling
  • Java Flight Recorder (JFR): Low-overhead production profiling

2. Memory & Heap Analysis

  • Heap dump analysis
  • Memory leak detection
  • Garbage collection tuning
  • Object allocation tracking

3. Thread & Concurrency

  • Thread contention detection
  • Deadlock identification
  • CPU sampling per thread
  • Wait time analysis

4. Database & I/O

  • JDBC query profiling
  • Connection pool monitoring
  • File I/O performance
  • Network latency tracking

Usage

YourKit Profiler

# Attach to running JVM
java -agentpath:/path/to/yjpagent.so MyApplication

# CPU profiling
# Memory allocation tracking
# Thread monitoring

VisualVM (Built-in)

# Launch VisualVM
jvisualvm

# Connect to local/remote JVM
# Monitor: CPU, Memory, Threads, Classes
# Profile: CPU sampling, Memory profiling

Java Flight Recorder

# Start JFR recording
java -XX:StartFlightRecording=duration=60s,filename=recording.jfr MyApp

# Analyze with JMC
jmc recording.jfr

JProfiler Integration

# Remote profiling
java -agentpath:/path/to/jprofilerti.so=port=8849 MyApplication

# Connect JProfiler GUI to port 8849

Integration Scripts

jvm_monitor.sh

Automated JVM health monitoring:

#!/bin/bash
# Monitor JVM performance metrics

PID=$(jps | grep MyApplication | awk '{print $1}')

echo "=== JVM Memory Usage ==="
jmap -heap $PID

echo "=== Thread Dump ==="
jstack $PID

echo "=== GC Statistics ==="
jstat -gcutil $PID 1000 5

heap_analyzer.sh

Heap dump analysis automation:

#!/bin/bash
# Generate and analyze heap dump

PID=$1
DUMP_FILE="heap_dump_$(date +%Y%m%d_%H%M%S).hprof"

jmap -dump:live,format=b,file=$DUMP_FILE $PID
echo "Heap dump created: $DUMP_FILE"

# Analyze with jhat or VisualVM
jhat $DUMP_FILE

Performance Tuning Guidelines

JVM Arguments for Profiling

-XX:+UseG1GC                          # Use G1 garbage collector
-XX:MaxGCPauseMillis=200              # Target max GC pause
-Xms2g -Xmx4g                         # Heap size (min/max)
-XX:+HeapDumpOnOutOfMemoryError       # Dump on OOM
-XX:HeapDumpPath=/tmp/heapdumps       # Dump location
-XX:+PrintGCDetails                   # GC logging
-XX:+PrintGCDateStamps                # Timestamp GC logs

Common Performance Issues

1. Memory Leaks

  • Growing heap usage over time
  • Increasing full GC frequency
  • OutOfMemoryError exceptions

Detection: Monitor heap growth pattern, analyze retained objects

2. Thread Contention

  • High CPU wait time
  • Deadlocks and livelocks
  • Poor scalability under load

Detection: Thread dumps, lock contention analysis

3. Database Performance

  • N+1 query problems
  • Missing connection pool configuration
  • Unoptimized JDBC batch sizes

Detection: SQL logging, JDBC profiling

4. GC Overhead

  • Long GC pause times
  • Frequent full GCs
  • High GC CPU usage

Detection: GC logs analysis, pause time distribution

Best Practices

  1. Start with Low-Overhead Tools: JFR for production, VisualVM for development
  2. Profile Realistic Workloads: Use production-like data volumes
  3. Focus on Hot Spots: Optimize methods consuming >10% CPU time
  4. Monitor GC Impact: Aim for <1% CPU time in GC
  5. Analyze Thread Dumps: Take 3-5 dumps, 10 seconds apart
  6. Use Sampling Mode initially, switch to instrumentation for deep analysis

Requirements

# Built-in tools (JDK 8+)
jvisualvm, jconsole, jmc, jstat, jmap, jstack, jhat

# Commercial tools (trial/licensed)
YourKit: https://www.yourkit.com/
JProfiler: https://www.ej-technologies.com/products/jprofiler/

Example Workflow

  1. Baseline: Capture performance metrics under normal load
  2. Profile: Run YourKit/JProfiler during load test
  3. Analyze: Identify CPU hot spots and memory allocations
  4. Optimize: Fix identified issues (algorithms, caching, pooling)
  5. Verify: Re-profile to confirm improvements
  6. Monitor: Set up continuous monitoring with JFR

Metrics to Track

  • Throughput: Requests/second
  • Latency: p50, p95, p99 response times
  • Memory: Heap usage, allocation rate
  • GC: Pause frequency and duration
  • Threads: Active thread count, wait time
  • CPU: Per-thread CPU time distribution

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.