Skip to content

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

Open
vetler wants to merge 30 commits intogithub:stagedfrom
vetler:add-async-profiler-skill-staged
Open

Add async-profiler skill for Java profiling 🤖🤖🤖#1400
vetler wants to merge 30 commits 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 focused guides
├── README.md                     # Human-readable overview
├── references/
│   ├── setup.md                  # Installation and configuration
│   ├── profile.md                # Running profiling sessions
│   └── analyze.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

@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,491 BPE tokens [chars/4: 1,589] (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,491 BPE tokens [chars/4: 1,589] (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 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/collect.sh
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/references/profile.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 Outdated
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/collect.sh Outdated
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh
vetler and others added 2 commits May 2, 2026 17:29
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 Outdated
Comment thread skills/async-profiler/SKILL.md
Comment thread skills/async-profiler/README.md
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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 2 comments.

Comment thread skills/async-profiler/references/setup.md Outdated
Comment thread skills/async-profiler/scripts/collect.sh
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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/references/setup.md Outdated
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 2 comments.

Comment thread skills/async-profiler/scripts/analyze_collapsed.py Outdated
Comment thread skills/async-profiler/scripts/collect.sh
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Comments suppressed due to low confidence (1)

skills/async-profiler/references/setup.md:1

  • The manual install section hard-codes v4.3 URLs in multiple places. Since scripts/install.sh pins the version and will likely change over time, these URLs will become stale unless updated in lockstep. Consider either (a) using a <VERSION> placeholder and explicitly instructing readers to substitute the version used in scripts/install.sh, or (b) pointing readers to the GitHub Releases page for the current version rather than embedding version-specific URLs.
# async-profiler Setup

Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/scripts/run_profile.sh Outdated
Comment thread skills/async-profiler/scripts/collect.sh Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread skills/async-profiler/references/setup.md Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread skills/async-profiler/scripts/install.sh
Comment thread skills/async-profiler/scripts/run_profile.sh
Comment thread skills/async-profiler/scripts/analyze_collapsed.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread skills/async-profiler/scripts/collect.sh
Comment thread skills/async-profiler/scripts/install.sh
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 11 out of 11 changed files in this pull request and generated 3 comments.

Comment on lines +353 to +363
# Note: on macOS, -f is silently ignored by asprof stop — handled below.
"$asprof" stop -f "$jfr_path" "$TARGET"
# Session file is removed only after the JFR is confirmed written (see end of block).

# ── macOS JFR path workaround ────────────────────────────────────────────
# On macOS, asprof stop ignores -f and writes the JFR to:
# /var/folders/<hash>/T/<timestamp>_<pid>/<timestamp>.jfr
# Use the sentinel (created at 'start') to find the file via find -newer.
if [[ "$(uname)" == "Darwin" ]] && [[ -n "$sentinel" ]] && [[ -f "$sentinel" ]]; then
echo ""
echo "⚠️ macOS: -f is ignored by asprof stop — locating JFR in /var/folders..."
Comment on lines +394 to +398
if [[ -n "$found_jfr" ]]; then
cp "$found_jfr" "$jfr_path"
rm -f "$sentinel"
echo " Found: $found_jfr"
echo " Copied to: $jfr_path"
echo " Output : $OUTPUT"
$THREADS && echo " Threads : separate"
echo ""
echo "▶ ${CMD[*]}"
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.

3 participants