system-profile
它能做什么
这个技能测量程序或系统的性能,例如 CPU、内存、GPU 或网络占用,并报告瓶颈。适合想弄清楚某件事为什么慢的开发者。
适用场景
- ✓当脚本或程序很慢,你想找出瓶颈时。
- ✓当你想在运行期间检查 GPU、内存或互连的使用情况时。
- ✓当你希望得到一份性能总结,并标明主要的慢速部分时。
技能链接
https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/blob/main/skills/skills-codex/system-profile/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的训练脚本很慢,请帮我对它进行性能剖析,并告诉我瓶颈在哪里。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会为目标选择剖析工具,例如 Python 剖析器或 GPU 监视器,并在需要时添加埋点代码。它会运行这些工具,分析结果,并写出总结。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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)
- Redundant replication: same data living on both CPU and GPU
- Per-device allocation balance in multi-GPU setups
Interconnect & communication
- CPU-GPU transfer: frequency, per-transfer size, total volume, bandwidth achieved
- GPU-GPU transfer: P2P bandwidth, NVLink vs PCIe topology impact
- NCCL collectives: operation type, message size distribution, latency
- Communication-to-computation ratio
GPU compute
- SM utilization, kernel launch overhead
- Memory bandwidth utilization vs peak
Step 4: Instrumentation guidelines
When inserting code into the target:
- Read and understand the target code first
- Prefer wrapping (decorator, context manager, standalone runner) over inline edits
- If inline edits are necessary, mark them clearly (e.g.,
# [PROFILE]comments) - Minimize observer effect — don't instrument tight inner loops; sample instead
- Collect results into a structured log, don't scatter print statements
Step 5: Run profiling
- Check available tools and hardware topology
- Run the chosen methods, capture all output
- Save artifacts (flamegraphs, traces, logs) to
./profile_output/
Step 6: Produce the report
Part A — Profiling results (structured tables by dimension, as applicable):
- CPU overhead table
- Memory overhead table (with redundancy column)
- Interconnect table (transfer type / frequency / size / latency / bandwidth)
- Hotspots / bottleneck identification
- Actionable recommendations ranked by expected impact
Part B — Instrumentation changelog (MANDATORY): List every file that was modified or created for profiling purposes:
| File | Change type | What was added/modified | Line(s) |
|---|---|---|---|
| ... | modified | ... | ... |
| ... | created | ... | — |
This allows the user to review and revert all instrumentation changes. Offer to clean up (remove all instrumentation) when the user is done.
常见问题
它可以剖析什么?
它可以剖析脚本、正在运行的进程、函数、GPU、内存,或 GPU 之间的连接。
它会修改我的代码吗?
它可能会编写埋点代码来测量程序的某些部分。该技能并未说明会重写你的主要逻辑。
如果目标不明确怎么办?
在开始之前,该技能会请你说明要剖析什么。
详情
作者的原始描述
Profile a target (script, process, GPU, memory, interconnect) for performance analysis. Use when user says \"profile\", \"benchmark\", \"bottleneck\", or wants performance analysis.
热度
- GitHub 星标
- 18k
- 排名
- #10618
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
ablation-planner
18k帮你的智能体为论文规划消融实验,在主要结果看起来不错之后,选出审稿人很可能会要求的测试。
alphaxiv
18k让你的智能体借助 AlphaXiv 摘要快速阅读一篇研究论文,并以完整文本或 LaTeX 源文件作为备用,只需提供 arXiv 链接或编号。
analyze-results
18k帮你的智能体分析机器学习实验结果,将各次运行与基线进行比较,并把数字整理成清晰的发现和后续步骤。
arxiv
18k让你的智能体在 arXiv 上搜索学术论文、阅读论文详情,并把 PDF 保存到你的文库中,用于某个研究主题。