mcpField
P
performance-investigation

performance-investigation

github.com/sveltejs开发88.5k151 次安装今天更新
代码仓库

关于 performance-investigation

面向开发者的仓库专用技能,用于比较不同分支的基准性能,并通过报告和 CPU 配置文件调查回归。它还提供针对性复测与运行时测试流程。

主要功能

  1. 01比较分支间基准性能
  2. 02生成回归报告和原始结果
  3. 03查看 CPU 配置摘要与差异
  4. 04运行指定基准测试
  5. 05提供运行时回归测试指引

适用场景

  1. 01检查分支是否较 main 退化
  2. 02根据基准差异查找热点
  3. 03复测指定的响应性基准
  4. 04通过测试验证性能改动

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/sveltejs/svelte --skill performance-investigation

安装后在 Claude Code 中输入/performance-investigation确认已加载。

详细介绍

快速开始

  1. 从你想测量的分支开始(例如 foo)。
  2. 运行:
pnpm bench:compare main foo

如果传入一个分支,bench:compare 会自动将其与 main 进行比较。

输出位置

  • 汇总报告:benchmarking/compare/.results/report.txt
  • 基准测试原始数据:
    • benchmarking/compare/.results/main.json
    • benchmarking/compare/.results/<your-branch>.json
  • CPU 性能分析文件(每项基准测试、每个分支):
    • benchmarking/compare/.profiles/main/*.cpuprofile
    • benchmarking/compare/.profiles/main/*.md
    • benchmarking/compare/.profiles/<your-branch>/*.cpuprofile
    • benchmarking/compare/.profiles/<your-branch>/*.md

.md 文件是根据 CPU 性能分析生成的摘要,通常是查看性能热点最快的方式。

建议的排查流程

  1. 打开 benchmarking/compare/.results/report.txt,先找出回退幅度最大的项目。
  2. 对于每项差异较大的基准测试,对比:
    • benchmarking/compare/.profiles/main/<benchmark>.md
    • benchmarking/compare/.profiles/<branch>/<benchmark>.md
  3. 查看运行时内部模块(runtime.js、reactivity/batch.js、reactivity/deriveds.js、reactivity/sources.js)中自身耗时和包含耗时的热点占比变化。
  4. 每次只做一项优化,然后重新运行目标基准测试,再重新运行完整比较。

快速基准测试循环

按子字符串只运行选定的响应式基准测试:

pnpm bench kairo_mux kairo_deep kairo_broad kairo_triangle
pnpm bench repeated_deps sbench_create_signals mol_owned

性能优化后要运行的测试

运行时响应式回归最可能出现在 runes 运行时测试中:

pnpm test runtime-runes

实用脚本

快速查看两个分支之间的 cpuprofile 热点差异:

node benchmarking/compare/profile-diff.mjs kairo_mux_owned main foo

此脚本会输出所选基准测试中函数样本占比的变化情况。

实际注意事项

  • bench:compare 运行时会切换分支。请避免保留未提交的更改(或将其暂存),以确保分支切换安全。
  • 每次运行 bench:compare 都会重写 benchmarking/compare/.results 和 benchmarking/compare/.profiles。

评论

支持 Markdown