跳到正文
Skillpedia
通用编程12k · #11547

investigate-puffin

它能做什么

这个技能让你的 AI 打开 Puffin 性能分析录制文件,找出应用中哪些部分耗时最多。适合希望在变更前后检查性能的开发者。

适用场景

  • ✓你有 .puffin 文件,想知道哪些代码运行缓慢的时候。
  • ✓你想比较变更前和变更后的跟踪记录的时候。
  • ✓你让 AI 使用 rerun dump-puffin 命令读取性能分析文件的时候。

技能链接

https://github.com/rerun-io/rerun/blob/main/skills/investigate-puffin/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/rerun-io/rerun/blob/main/skills/investigate-puffin/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请看看这个 .puffin 录制文件,并告诉我哪些函数耗时最长。”

每周 5 个新技能,1 分钟读完。

工作原理

这个技能使用 rerun dump-puffin 命令把录制文件转换为 JSON,然后借助小型辅助脚本找出耗时最长的作用域,并比较两次运行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Investigate puffin traces

Analyze a .puffin recording from an application instrumented with Puffin. Use the recording path supplied by the user. Or use the capture_profile_trace message if using the rerun MCP.

Setup

Requires the rerun CLI (Rerun 0.38 or later), Python 3.10 or later, and jq. The Python helpers use only the standard library. Set PUFFIN_SKILL_DIR to the absolute directory containing this SKILL.md. In Claude Code, you can use export PUFFIN_SKILL_DIR="${CLAUDE_SKILL_DIR}"; in other agents, resolve the directory from the installed skill location.

Dump the trace to a file and check scope registration:

rerun dump-puffin <path> > /tmp/puffin.json
jq '.scopes | length' /tmp/puffin.json

If no (recent enough) rerun binary is on the path but you are in a Rerun checkout, run the sub-command from source instead:

cargo run --quiet -p rerun-cli --no-default-features -- dump-puffin <path> > /tmp/puffin.json

Always dump to a file. .puffin traces can produce many MB of JSON, so query the saved JSON instead of reading it all into context.

If .scopes | length is 0, names fall back to scope#<id> and source locations are missing. Ask for a new capture that includes scope registration if names are needed for the investigation. If another capture is not feasible, proceed with dynamic data labels and explain the limits. Check the registration table after exporting: do not assume that every capture tool or version preserves it.

How traces are captured

Use the application's Puffin capture or export support to save a .puffin file. For applications serving profiling data through puffin_http, connect a compatible puffin_viewer and export the recording. The dumper uses Puffin 0.20; captures from incompatible format versions may require a matching parser.

Rerun-specific examples:

  • Native viewer / CLI: enable the built-in Puffin server from the UI.
  • Python SDK: set RERUN_PUFFIN=1 before importing rerun to stream profiling data to puffin_viewer.
  • Rust binaries using re_tracing: keep a re_tracing::Profiler alive for the capture and call its start() method with server support enabled. It starts a server and attempts to launch puffin_viewer.

Investigate with jq

The JSON layout:

{
  "file": "preview.puffin",
  "scopes": { "<id>": { name, function, file, line, kind } },   # may be empty — see Setup
  "frames": [
    {
      "frame_index": …,
      "range_ns": [start, end],
      "duration_ns": …,
      "num_scopes": …,
      "threads": [
        {
          "name": "main",
          "num_scopes": …, "depth": …, "range_ns": […],
          "scopes": [ { id, name, start_ns, duration_ns, data, children: […] } ]
        }
      ]
    }
  ]
}

name on each scope is resolved from the scopes map. data is the dynamic per-call string, such as an event type or a mesh name.

Recipes

Footgun: any .. | objects | select(.name? == …) pattern MUST also select(has("duration_ns")). .. walks every object in the tree, including entries in the top-level scopes registration map, which have .name but no .duration_ns. Without the guard you will hit null / 1e6 errors or sort against null. Every recipe below includes the guard, keep it when adapting them.

Prefer find_scopes.py for name/data lookups. If you just want "slowest matches of X", "total time grouped by name" or "all scopes matching X on thread Y", reach for find_scopes.py instead of writing jq, it's shorter and bakes the guard in. See "Looking for a scope by prefix" below. Use the jq recipes here when you need something the script does not cover (children of a specific scope, cross-thread windows, time-ordered traversal).

# overall shape — sorted slowest first so the bad frames jump out
jq '.frames | map({i: .frame_index, ms: (.duration_ns / 1e6), scopes: .num_scopes}) | sort_by(-.ms)' /tmp/puffin.json

# per-thread totals for the slowest frame
jq '.frames | sort_by(-.duration_ns) | .[0].threads | map({name, num_scopes, depth, ms: ((.range_ns[1] - .range_ns[0]) / 1e6)})' /tmp/puffin.json

# top 10 slowest individual scopes (recursive descent over the whole tree)
# also doable as: find_scopes.py /tmp/puffin.json '' --top 10
jq '[.. | objects | select(has("duration_ns") and has("name"))]
    | sort_by(-.duration_ns) | .[0:10]
    | map({name, data, ms: (.duration_ns / 1e6)})' /tmp/puffin.json

# total time per scope name (best-effort: group
常见问题

我需要安装什么?

这个技能需要 0.38 或更新版本的 rerun 命令行工具、Python 3.10 或更新版本,以及 jq。

为什么要把跟踪记录保存为文件?

Puffin 跟踪记录可能有数兆字节,因此这个技能会查询已保存的 JSON,而不是全部读取。

如果名称看起来像 scope# 怎么办?

这意味着录制文件中没有作用域名称,这个技能会要求你重新采集一份包含名称的录制。

详情

作者的原始描述

Investigate Puffin profiler recordings (.puffin files), find slow scopes, and compare before/after traces using the `rerun dump-puffin` command and bundled analysis helpers.

repo: rerun-io/rerun

热度

GitHub 星标
12k
排名
#11547
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能