# Java Performance

> JVM performance tuning - GC optimization, profiling, memory analysis, benchmarking

- **Type:** Skill
- **Install:** `agentstack add skill-linlannet-agent-skills-java-performance`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [linlannet](https://agentstack.voostack.com/s/linlannet)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [linlannet](https://github.com/linlannet)
- **Source:** https://github.com/linlannet/agent-skills/tree/main/skills/java-performance

## Install

```sh
agentstack add skill-linlannet-agent-skills-java-performance
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Java 性能技能

通过分析、GC 调优和内存分析优化 JVM 性能。

## 概述

本技能涵盖 JVM 性能优化，包括垃圾收集调优、内存分析、CPU 分析和使用 JMH 进行基准测试。

## 何时使用此技能

当您需要以下操作时使用：
- 为低延迟或吞吐量调优 GC
- 分析 CPU 热点
- 分析内存泄漏
- 基准测试代码性能
- 优化容器设置

## 快速参考

### GC 预设

```bash
# High-throughput
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-Xms4g -Xmx4g
-XX:+AlwaysPreTouch

# Low-latency
-XX:+UseZGC
-XX:+ZGenerational
-Xms8g -Xmx8g

# Memory-constrained
-XX:+UseSerialGC
-Xms512m -Xmx512m
-XX:+UseCompressedOops

# Container-optimized
-XX:+UseContainerSupport
-XX:MaxRAMPercentage=75.0
-XX:+ExitOnOutOfMemoryError
```

### 分析命令

```bash
# Thread dump
jstack -l  > threaddump.txt

# Heap dump
jmap -dump:format=b,file=heap.hprof 

# GC analysis
jstat -gcutil  1000 10

# Flight recording
jcmd  JFR.start duration=60s filename=app.jfr

# Async profiler
./profiler.sh -d 30 -f profile.html 
```

### JMH 基准测试

```java
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 3, time = 1)
@Measurement(iterations = 5, time = 1)
@State(Scope.Benchmark)
public class MyBenchmark {

    @Benchmark
    public void testMethod(Blackhole bh) {
        bh.consume(compute());
    }
}
```

## GC 比较

| GC | 延迟 | 吞吐量 | 堆大小 |
|----|------|--------|--------|
| G1 | 中等 | 高 | 4-32GB |
| ZGC | 极低 | 中等 | 8GB-16TB |
| Shenandoah | 极低 | 中等 | 8GB+ |
| Parallel | 高 | 极高 | 任意 |

## 故障排除

| 问题 | 原因 | 解决方案 |
|------|------|----------|
| GC 抖动 | 堆太小 | 增加堆大小 |
| 高延迟 | GC 暂停 | 切换到 ZGC |
| 内存泄漏 | 对象保留 | 堆转储 + MAT |
| CPU 峰值 | 热点循环 | 分析 + 优化 |

## 使用方法

```
Skill("java-performance")
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [linlannet](https://github.com/linlannet)
- **Source:** [linlannet/agent-skills](https://github.com/linlannet/agent-skills)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-linlannet-agent-skills-java-performance
- Seller: https://agentstack.voostack.com/s/linlannet
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
