-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add async-profiler skill for Java profiling π€π€π€ #1400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vetler
wants to merge
2
commits into
github:staged
Choose a base branch
from
vetler:add-async-profiler-skill-staged
base: staged
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # async-profiler | ||
|
|
||
| Install, run, and analyze async-profiler for Java β a low-overhead sampling profiler producing flamegraphs, JFR recordings, and allocation profiles. | ||
|
|
||
| ## What it does | ||
|
|
||
| - Installs async-profiler automatically for macOS or Linux | ||
| - Captures CPU time, heap allocations, wall-clock time, and lock contention | ||
| - Produces interactive flamegraphs, JFR recordings, and collapsed stack traces | ||
| - Interprets profiling output: identifies hotspots, GC pressure, lock contention, N+1 Hibernate patterns | ||
|
|
||
| ## Compatibility | ||
|
|
||
| Requires Python 3.7+ for the analysis script. async-profiler works on macOS and Linux with a running JVM process. | ||
|
|
||
| ## Installation | ||
|
|
||
| **GitHub Copilot CLI:** | ||
|
|
||
| Point Copilot at the skill directory from within a session: | ||
| ``` | ||
| /skills add /path/to/async-profiler | ||
| ``` | ||
|
|
||
| Or copy manually to your personal skills directory (`~/.copilot/skills/` or `~/.agents/skills/` depending on your version): | ||
| ```bash | ||
| cp -r async-profiler ~/.copilot/skills/ | ||
| # or | ||
| cp -r async-profiler ~/.agents/skills/ | ||
| ``` | ||
|
|
||
| **Claude Code:** | ||
| ```bash | ||
| cp -r async-profiler ~/.claude/skills/async-profiler | ||
| ``` | ||
|
|
||
| **OpenCode:** | ||
| ```bash | ||
| cp -r async-profiler ~/.config/opencode/skills/async-profiler | ||
| ``` | ||
|
|
||
| ## Trigger phrases | ||
|
|
||
| - "install async-profiler" | ||
| - "capture a flamegraph" | ||
| - "profile my Spring Boot app" | ||
| - "heap keeps growing" | ||
| - "what does this flamegraph mean" | ||
| - "I see a lot of GC in my profile" | ||
|
|
||
| ## Bundled scripts | ||
|
|
||
| | Script | Purpose | | ||
| |---|---| | ||
| | `scripts/install.sh` | Auto-detect platform, download and verify async-profiler | | ||
| | `scripts/run_profile.sh` | Wrap `asprof` with defaults, timestamp output | | ||
| | `scripts/collect.sh` | Background collection: start all-event profiling, stop and retrieve flamegraphs | | ||
| | `scripts/analyze_collapsed.py` | Ranked self-time/inclusive-time table for `.collapsed` files | | ||
|
|
||
| ## Directory structure | ||
|
|
||
| ``` | ||
| async-profiler/ | ||
| βββ SKILL.md # Entry point β routes to sub-guides | ||
| βββ scripts/ # Bundled scripts | ||
| βββ setup/ | ||
| β βββ SKILL.md # Installation and configuration | ||
| βββ profile/ | ||
| β βββ SKILL.md # Running profiling sessions | ||
| βββ analyze/ | ||
| βββ SKILL.md # Interpreting profiling output | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| --- | ||
| name: async-profiler | ||
| description: 'Install, run, and analyze async-profiler for Java β low-overhead sampling profiler producing flamegraphs, JFR recordings, and allocation profiles. Use for: "install async-profiler", "set up Java profiling", "Failed to open perf_events", "what JVM flags for profiling", "capture a flamegraph", "profile CPU/memory/allocations/lock contention", "profile my Spring Boot app", "generate a JFR recording", "heap keeps growing", "what does this flamegraph mean", "how do I read a flamegraph", "interpret profiling results", "open a .jfr file", "what''s causing my CPU hotspot", "wide frame in my profile", "I see a lot of GC / Hibernate / park in my profile". Use this skill any time a Java developer mentions profiling, flamegraphs, async-profiler, JFR, or wants to understand JVM performance.' | ||
| compatibility: Requires Python 3.7+ for the analyze_collapsed.py script. | ||
|
vetler marked this conversation as resolved.
|
||
| --- | ||
|
|
||
| # async-profiler | ||
|
|
||
| async-profiler is a production-safe, low-overhead sampling profiler for Java | ||
| that avoids the safepoint bias of standard JVM profilers. It can capture CPU | ||
| time, heap allocations, wall-clock time, and lock contention, and produce | ||
| interactive flamegraphs, JFR recordings, and collapsed stack traces. | ||
|
|
||
| ## Installing this skill | ||
|
|
||
| ### IntelliJ IDEA (Junie or GitHub Copilot) | ||
|
|
||
| Skills live in a `.claude/skills/`, `.agents/skills/`, or `.github/skills/` | ||
| directory, either in your project repo or in your home directory. | ||
|
|
||
| **Project-level β recommended for teams** (commit so everyone gets it): | ||
| ```bash | ||
| # From your project root: | ||
| mkdir -p .github/skills | ||
| cd .github/skills | ||
| unzip /path/to/async-profiler.skill | ||
| git add async-profiler | ||
| git commit -m "Add async-profiler skill" | ||
| ``` | ||
|
|
||
| **Global β personal use across all projects:** | ||
| ```bash | ||
| mkdir -p ~/.claude/skills | ||
| cd ~/.claude/skills | ||
| unzip /path/to/async-profiler.skill | ||
| ``` | ||
|
|
||
| > **Note for GitHub Copilot users:** There is a known issue where the Copilot | ||
| > JetBrains plugin does not reliably pick up skills from the global `~/.copilot/skills` | ||
| > directory. Use the project-level `.github/skills/` location to be safe. | ||
|
|
||
| Alternatively, install the **Agent Skills Manager** plugin from the JetBrains | ||
| Marketplace (*Settings β Plugins β Marketplace* β "Agent Skills Manager") for | ||
| a UI that installs skills without unzipping manually. | ||
|
|
||
| --- | ||
|
|
||
| ## Using this skill in IntelliJ IDEA | ||
|
|
||
| ### With Junie (JetBrains AI) | ||
|
|
||
| Junie is JetBrains' native coding agent, available in the AI Chat panel. | ||
|
|
||
| 1. Open the AI Chat panel (*View β Tool Windows β AI Chat*, or the chat icon | ||
| in the right toolbar) | ||
| 2. In the agent dropdown at the top of the chat, select **Junie** | ||
| 3. Choose a mode: | ||
| - **Code mode** β Junie can run terminal commands, write files, and execute | ||
| the profiling scripts directly. Use this when you want it to actually run | ||
| `scripts/install.sh` or `scripts/run_profile.sh` for you. | ||
| - **Ask mode** β read-only; Junie analyzes and explains but won't touch | ||
| files. Use this when you want help interpreting a flamegraph or JFR file. | ||
| 4. Just ask naturally β Junie loads the skill automatically when your question | ||
| matches the description. You don't need to invoke it by name. | ||
|
|
||
| Example prompts that will trigger this skill in Junie: | ||
| - *"My Spring Boot app is using too much CPU. Help me capture a flamegraph."* | ||
| - *"I have this JFR file β open it and tell me what's slow."* | ||
| - *"Install async-profiler on this machine and set up the JVM flags."* | ||
|
|
||
| In Code mode, Junie will run `scripts/install.sh`, execute `scripts/run_profile.sh` | ||
| with the right flags, and then walk you through the results β all without | ||
| leaving IntelliJ. | ||
|
|
||
| ### With GitHub Copilot in IntelliJ | ||
|
|
||
| 1. Enable agent mode: *Settings β GitHub Copilot β Chat β Agent* β turn on | ||
| **Agent mode** and **Agent Skills** | ||
| 2. Open the Copilot Chat panel and make sure the mode selector shows **Agent** | ||
| 3. Ask naturally β Copilot loads the skill when your prompt matches | ||
|
|
||
| Example prompts: | ||
| - *"Profile my running Java app and show me where the CPU is going."* | ||
| - *"Analyze this collapsed stack file and tell me what's allocating the most."* | ||
|
|
||
| GitHub Copilot's agent mode can also run the bundled scripts on your behalf β | ||
| it will propose the terminal command and ask for confirmation before executing. | ||
|
|
||
| ### GitHub Copilot CLI | ||
|
|
||
| ```bash | ||
| # Copilot CLI | ||
| mkdir -p ~/.copilot/skills | ||
| cd ~/.copilot/skills | ||
| unzip /path/to/async-profiler.skill | ||
|
|
||
| # Or, if your version uses ~/.agents/skills/: | ||
| mkdir -p ~/.agents/skills | ||
| cd ~/.agents/skills | ||
| unzip /path/to/async-profiler.skill | ||
| ``` | ||
|
vetler marked this conversation as resolved.
|
||
|
|
||
| Run `/skills list` to confirm it loaded. Then just ask naturally in the terminal. | ||
|
|
||
| --- | ||
|
|
||
| ## Bundled scripts | ||
|
|
||
| This skill includes four ready-to-run scripts in `scripts/`: | ||
|
|
||
| | Script | What it does | | ||
| |---|---| | ||
| | `scripts/install.sh` | Auto-detects platform, downloads the right binary, verifies install | | ||
| | `scripts/run_profile.sh` | Wraps `asprof` with defaults, timestamps output, prints opening instructions | | ||
| | `scripts/collect.sh` | Agent-friendly background collection: start all-event profiling, do other work, then stop and get all flamegraphs | | ||
| | `scripts/analyze_collapsed.py` | Ranked self-time / inclusive-time table for `.collapsed` files, with filters | | ||
|
|
||
| Always offer to run these scripts on the user's behalf when relevant. | ||
|
|
||
| ## How to use this skill | ||
|
|
||
| This skill has three sub-guides. Read the one that matches what the user needs: | ||
|
|
||
| | Situation | Read | | ||
| |---|---| | ||
| | User needs to install or configure async-profiler, or is hitting setup errors | `setup/SKILL.md` | | ||
| | User wants to run a profiling session (capture flamegraph, JFR, etc.) | `profile/SKILL.md` | | ||
| | User has profiling output and wants to understand or interpret it | `analyze/SKILL.md` | | ||
|
|
||
| **When the conversation spans multiple phases** (e.g., the user just ran a | ||
| profile and now wants to understand the output), read whichever sub-guide is | ||
| most relevant to the current question. If the user needs both setup *and* | ||
| profiling guidance in one message, read `setup/SKILL.md` first and summarize | ||
| the setup steps before moving to `profile/SKILL.md`. | ||
|
|
||
| Read the relevant sub-guide now before responding. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.