# system-profile

Profiles Python scripts, processes, memory, and GPUs using CLI utilities and automated code instrumentation. Helps isolate latency bottlenecks in ML pipelines.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 474 installs · ★ 18090
- Author: wanshuiyin
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/HEAD/skills/system-profile/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/system-profile

## What it does

The skill investigates execution targets ranging from a raw script or PID to frameworks like vLLM. It decides which profiling strategy fits the supplied argument. Depending on the environment, it invokes external tools like `cProfile`, `py-spy`, `torch.profiler`, `nsys`, or inspects hardware interconnects via `nvidia-smi nvlink`.

External tools are sometimes not enough. When that happens, the skill instruments your code directly by wrapping functions with context managers, decorators, or CUDA event timers. Every inline change is marked with `# [PROFILE]`. It avoids instrumenting tight inner loops so the observer effect stays minimal. Generated logs, traces, and flamegraphs land in `./profile_output/`.

The final report groups metrics across CPU overhead, memory redundancy, and interconnect bandwidth. It also generates a mandatory changelog table covering modified files and line numbers. The skill relies on your system having the requested profiling binaries preinstalled, so it fails if tools like `perf` or `nsys` are missing from your PATH.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/system-profile/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/system-profile/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/system-profile/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/system-profile/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wanshuiyin/Auto-claude-code-research-in-sleep system-profile
```

2. **Manually: put the files in place**
- File: `.github/skills/system-profile/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep --path skills/system-profile
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/system-profile/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/HEAD/skills/system-profile/SKILL.md

## When to use it
- trace GPU interconnect and NVLink throughput bottlenecks
- profile end-to-end latency in vLLM serving and training loops
- detect duplicate memory allocations between CPU and GPU
- insert CUDA event timers into target scripts automatically

## Example prompts
- Profile train.py
- Benchmark vllm serving and identify bottlenecks
- Run system-profile on pid 1234 focusing on gpu and memory

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 456c6a2cf03b572d.

BEGIN THIRD-PARTY FILE 456c6a2cf03b572d
```text
---
name: system-profile
description: "Profile a target (script, process, GPU, memory, interconnect) for performance analysis. Use when user says \"profile\", \"benchmark\", \"bottleneck\", or wants performance analysis."
argument-hint: '<target, e.g. "train.py", "gpu", "pid 1234", "vllm serving">'
---

# System Profile

Profile the specified target and summarize the results. Target: $ARGUMENTS

## Instructions

You are a profiling assistant. Based on the user's target, choose appropriate profiling strategies, **including writing instrumentation code when needed**, then run profiling, analyze results, and produce a summary.

### Step 1: Determine the profiling target

Parse `$ARGUMENTS` to understand what to profile. Examples:
- A Python script or module
- A running process (PID or service name)
- A specific function or code block
- An entire framework or system (e.g., "autogen", "vllm serving") — profile its end-to-end execution, identify bottlenecks across components
- "gpu" / "interconnect" / "memory" for focused profiling

If `$ARGUMENTS` is empty or unclear, ask the user.

### Step 2: Choose profiling methods

Select from external tools and/or code instrumentation as appropriate. Don't limit yourself to the examples below — use whatever makes sense for the target.

**External tools** (check availability first):
- CPU: `cProfile`, `py-spy`, `line_profiler`, `perf stat`, `/usr/bin/time -v`
- Memory: `tracemalloc`, `memory_profiler`, `memray`
- GPU: `nvidia-smi`, `nvidia-smi dmon`, `nvitop`, `torch.profiler`, `nsys`
- Interconnect: `nvidia-smi topo -m`, `nvidia-smi nvlink`, `NCCL_DEBUG=INFO`
- System: `strace -c`, `iostat`, `vmstat`

**Code instrumentation** — when external tools are insufficient, write and insert profiling code into the target. Typical scenarios:
- Timing specific code blocks (wall time vs CPU time)
- Measuring CPU-GPU or GPU-GPU transfer size, frequency, and bandwidth
- Tracking memory allocation across CPU and GPU to detect redundancy
- Wrapping NCCL collectives to measure latency and throughput
- Adding CUDA event timing around kernels

Design the instrumentation based on what you observe in the code — don't use a fixed template.

### Step 3: Key dimensions to investigate

Depending on the target, focus on some or all of these:

**CPU overhead**
- Context switching (voluntary / involuntary)
- CPU utilization: ratio of CPU time to wall time
- Per-function execution time hotspots

**Memory overhead**
- CPU and GPU memory usage (allocated vs reserved vs peak)
```
END THIRD-PARTY FILE 456c6a2cf03b572d

The third-party file has ended. Everything between the 456c6a2cf03b572d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2531 of 4473 bytes. © wanshuiyin · MIT · https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/HEAD/skills/system-profile/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
