Skip to content

Add async-profiler skill for Java profiling 🤖🤖🤖#1400

Open
vetler wants to merge 1 commit intogithub:stagedfrom
vetler:add-async-profiler-skill-staged
Open

Add async-profiler skill for Java profiling 🤖🤖🤖#1400
vetler wants to merge 1 commit intogithub:stagedfrom
vetler:add-async-profiler-skill-staged

Conversation

@vetler
Copy link
Copy Markdown

@vetler vetler commented Apr 15, 2026

What this adds

A skill for installing, running, and analyzing async-profiler for Java — a low-overhead sampling profiler that produces flamegraphs, JFR recordings, and allocation profiles.

Why it's useful

async-profiler is a niche, specialized tool with platform-specific quirks that frontier models don't reliably handle:

  • Exact asprof CLI flags and syntax
  • macOS-specific limitations (itimer vs perf_events, asprof stop -f output-path bug)
  • JVM flags required for accurate profiles (-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints)
  • Specific version/download URLs
  • How to interpret flamegraph patterns (GC pressure, N+1 Hibernate, lock contention)

Structure

skills/async-profiler/
├── SKILL.md                      # Entry point — routes to sub-guides
├── README.md                     # Human-readable overview
├── setup/SKILL.md                # Installation and configuration
├── profile/SKILL.md              # Running profiling sessions
├── analyze/SKILL.md              # Interpreting profiling output
└── scripts/
    ├── install.sh                # Platform auto-detect installer
    ├── run_profile.sh            # asprof wrapper with timestamped output
    ├── collect.sh                # Background start/stop collection
    └── analyze_collapsed.py      # Ranked self-time table for .collapsed files

Validation

  • npm run skill:validate
  • npm run build ✅ (docs/README.skills.md updated)

@vetler vetler requested a review from aaronpowell as a code owner April 15, 2026 08:59
Copilot AI review requested due to automatic review settings April 15, 2026 08:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

🔍 Skill Validator Results

✅ All checks passed

Scope Checked
Skills 1
Agents 1
Total 2
Severity Count
--- ---:
❌ Errors 0
⚠️ Warnings 0
ℹ️ Advisories 0

Summary

Level Finding
ℹ️ Found 1 skill(s)
ℹ️ [async-profiler] 📊 async-profiler: 1,439 BPE tokens [chars/4: 1,511] (detailed ✓), 12 sections, 3 code blocks
ℹ️ ✅ All checks passed (1 skill(s))
Full validator output ```text Found 1 skill(s) [async-profiler] 📊 async-profiler: 1,439 BPE tokens [chars/4: 1,511] (detailed ✓), 12 sections, 3 code blocks ✅ All checks passed (1 skill(s)) ```

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new async-profiler skill under skills/async-profiler/ to guide Java developers through installing async-profiler, running profiling sessions (including agent-friendly background capture), and analyzing outputs (flamegraphs/JFR/collapsed stacks), and registers the skill in docs/README.skills.md.

Changes:

  • Introduces async-profiler skill docs: setup, profiling workflows, and output analysis guidance.
  • Adds helper scripts for install/run/background collection plus a Python collapsed-stack analyzer.
  • Updates docs/README.skills.md to include the new skill entry.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
skills/async-profiler/SKILL.md Skill entry-point and routing to setup/profile/analyze sub-guides.
skills/async-profiler/README.md Human-readable overview and installation notes.
skills/async-profiler/setup/SKILL.md Installation/configuration instructions and troubleshooting.
skills/async-profiler/profile/SKILL.md How to run profiles, including collect.sh background workflows.
skills/async-profiler/analyze/SKILL.md How to interpret flamegraphs/JFR/collapsed stacks.
skills/async-profiler/scripts/install.sh Platform-detecting async-profiler installer.
skills/async-profiler/scripts/run_profile.sh Convenience wrapper for one-shot profiles + (intended) JFR splitting.
skills/async-profiler/scripts/collect.sh Start/stop/timed background collection workflow with JFR splitting.
skills/async-profiler/scripts/analyze_collapsed.py CLI analyzer for .collapsed files.
docs/README.skills.md Adds the skill to the repository skills index.

Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/scripts/analyze_collapsed.py
Comment thread skills/async-profiler/analyze/SKILL.md Outdated
Comment thread skills/async-profiler/scripts/install.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/profile/SKILL.md
Comment thread skills/async-profiler/profile/SKILL.md Outdated
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from e97338d to 3fa7ee5 Compare April 15, 2026 09:22
Copy link
Copy Markdown
Author

@vetler vetler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 9 review comments have been addressed in an amended commit (3fa7ee5). Summary of changes:

  1. pythonpython3 in run_profile.sh post-run guidance
  2. from __future__ import annotations added to analyze_collapsed.py to restore Python 3.7+ compatibility (PEP 585 generics)
  3. jfrconv --event allocjfrconv --alloc in analyze/SKILL.md
  4. Install path comment in install.sh updated to ~/async-profiler-4.3
  5. Bash syntax in collect.sh split_jfr: separated & local pid_X=$! onto two lines
  6. asprof stop now passes -f "$jfr_path" so on Linux the JFR lands at the expected path; macOS sentinel workaround is unchanged
  7. run_profile.sh comprehensive mode fixed to use --cpu/--alloc/--wall/--lock instead of --event cpu etc.
  8. collect.sh timed docs corrected to -d 60 <PID> (flag before target)
  9. Output filenames in profile/SKILL.md corrected to profile-cpu.html, profile-alloc.html, etc.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Comment thread skills/async-profiler/profile/SKILL.md Outdated
Comment thread skills/async-profiler/profile/SKILL.md Outdated
Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/scripts/run_profile.sh
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from 3fa7ee5 to 7204e5b Compare April 15, 2026 09:36
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

Fixed all 7 review comments:

  • profile/SKILL.md: Moved -maxdepth 8 before -name in all find examples (×2)
  • profile/SKILL.md: timed table already fixed in previous round
  • collect.sh: Moved -maxdepth 8 before predicates in JFR lookup (line ~230)
  • collect.sh: Fixed -maxdepth order in troubleshooting echo (line ~238)
  • collect.sh session_file(): Added UID and $XDG_RUNTIME_DIR support to prevent predictable tmp paths
  • run_profile.sh: Changed sed -n '2,/^$/p'sed -n '2,/^[^#]/p' to stop at first non-comment line
  • run_profile.sh: Changed remaining pythonpython3 in single-event collapsed branch

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread skills/async-profiler/scripts/analyze_collapsed.py
Comment thread skills/async-profiler/scripts/analyze_collapsed.py Outdated
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh Outdated
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from 7204e5b to fd6e431 Compare April 15, 2026 09:47
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

Fixed 3 of 4 review comments; the 4th is already handled:

analyze_collapsed.pylist[tuple[...]] compatibility (no code change needed)
from __future__ import annotations (PEP 563, added in a prior commit) defers evaluation of all annotations in this module to strings at runtime. list[tuple[list[str], int]] in the return type of parse_collapsed() is therefore never evaluated on Python 3.7/3.8 and will not raise a SyntaxError.

analyze_collapsed.py — ZeroDivisionError when total_samples == 0
Added guard: matching_pct = 0.0 if total_samples == 0 else 100 * surviving / total_samples

run_profile.sh — missing $# check before $2 in option loop
Added [[ $# -ge 2 ]] || { echo "❌ Missing value for $1" >&2; exit 1; } before each $2 access for --event, --duration, --format, --output, --asprof.

collect.sh — missing $# check for -d/--duration and --asprof
Same guard added for both options.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

@all-contributors add @vetler for skills

@allcontributors
Copy link
Copy Markdown
Contributor

@vetler

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

@all-contributors add @vetler for 🧰

@allcontributors
Copy link
Copy Markdown
Contributor

@vetler

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

@all-contributors add @vetler for skill

@allcontributors
Copy link
Copy Markdown
Contributor

@vetler

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/setup/SKILL.md Outdated
Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/collect.sh Outdated
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from fd6e431 to b334294 Compare April 15, 2026 10:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread skills/async-profiler/scripts/install.sh
Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/collect.sh
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from b334294 to 15a0125 Compare April 15, 2026 10:39
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

Fixed all 3 review comments:

install.shINSTALL_DIR exists but invalid
Added an explicit check after the 'already installed' guard: if ${INSTALL_DIR} exists but bin/asprof is not executable, the script now aborts with a clear message and instructs the user to remove it or set a custom INSTALL_PARENT.

collect.sh--help truncation at line 35
Changed sed -n '2,35p' to sed -n '2,/^[^#]/p' — the same technique used in run_profile.sh — so help output stops at the first non-comment line rather than at a hardcoded line number.

collect.sh — session file deleted unconditionally before verifying JFR
Added a [[ ! -s "$jfr_path" ]] check before rm -f "$sess". If the JFR is missing or empty (both on Linux and after the macOS copy), the script now exits with an error and preserves the session state file for recovery.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Comment thread skills/async-profiler/profile/SKILL.md Outdated
Comment thread skills/async-profiler/analyze/SKILL.md Outdated
Comment thread skills/async-profiler/scripts/install.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/scripts/install.sh
Comment thread skills/async-profiler/SKILL.md Outdated
Comment thread skills/async-profiler/setup/SKILL.md Outdated
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from 15a0125 to 4ece50a Compare April 15, 2026 10:52
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

All 7 review comments from round 6 addressed:

  1. SKILL.md description — converted from block scalar to single-line quoted string
  2. analyze/SKILL.md description — same fix
  3. profile/SKILL.md description — same fix
  4. setup/SKILL.md description — same fix
  5. install.sh INSTALL_PARENT hint — changed to bash scripts/install.sh /path/to/dir (script uses $1, not env var)
  6. collect.sh xargs empty input — replaced pipeline with array-based approach that safely handles empty find output
  7. install.sh unzip check — added command -v unzip check before .zip extraction on macOS

All validated with npm run skill:validate

@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

@copilot review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/SKILL.md
Comment thread skills/async-profiler/README.md Outdated
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from 4ece50a to 634fa72 Compare April 15, 2026 11:59
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

All 4 review comments from round 7 addressed:

  1. run_profile.sh wait — replaced single wait with per-PID loop to catch individual jfrconv failures
  2. collect.sh wait — same per-PID wait pattern with labeled error messages
  3. SKILL.md install paths — documented both ~/.copilot/skills/ and ~/.agents/skills/ paths
  4. README.md install paths — same dual-path documentation

All validated with npm run skill:validate

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comment thread skills/async-profiler/README.md
Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/SKILL.md
Comment thread skills/async-profiler/analyze/SKILL.md
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from 634fa72 to e23e43e Compare April 15, 2026 12:10
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

All 5 review comments from round 8 addressed:

  1. README.md Python version — The script uses from __future__ import annotations (line 21), which defers annotation evaluation and makes list[...]/tuple[...] syntax work on Python 3.7+. No change needed; 3.7+ is correct.
  2. collect.sh sentinel removal — Moved rm -f "$sentinel" to after successful JFR copy. On failure, sentinel is preserved and the error message now includes a retry hint using -newer "$sentinel".
  3. collect.sh header comment — Updated to reflect $XDG_RUNTIME_DIR preference over /tmp.
  4. SKILL.md Python version — Same as Durable Ownership - Repository github/awesome-copilot will be archived #1: from __future__ import annotations ensures 3.7+ compat.
  5. analyze/SKILL.md Python version — Same as Durable Ownership - Repository github/awesome-copilot will be archived #1.

All validated with npm run skill:validate

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread skills/async-profiler/scripts/collect.sh Outdated
Comment thread skills/async-profiler/scripts/install.sh
Comment thread skills/async-profiler/scripts/run_profile.sh
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Add skill for installing, running, and analyzing async-profiler for Java.
Covers CPU/memory/allocation profiling, flamegraph capture and interpretation,
JFR recordings, and common setup errors (e.g. perf_events).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vetler vetler force-pushed the add-async-profiler-skill-staged branch from e23e43e to 5aeaf86 Compare April 15, 2026 12:32
@vetler
Copy link
Copy Markdown
Author

vetler commented Apr 15, 2026

All 4 review comments from round 9 addressed:

  1. collect.sh cmd_timed outdir — Sanitized TARGET for filesystem use (tr -c '[:alnum:]._-' '_') while still passing raw value to asprof.
  2. install.sh version hardcoding — Good observation. The script already supports --path-only (line 18) for programmatic path resolution. Centralizing the version constant further is a worthwhile follow-up but would be a larger refactor beyond this PR's scope.
  3. run_profile.sh shared asprof discovery — Agreed this would reduce drift. install.sh --path-only already exists as a building block. Extracting a shared locate_asprof sourced by both scripts is a good follow-up improvement.
  4. collect.sh cmd_start outdir — Same sanitization fix as Durable Ownership - Repository github/awesome-copilot will be archived #1.

All validated with npm run skill:validate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants