performance-investigation

作者: sveltejs

调查性能回归问题,并寻找优化机会

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

Quick start

  1. Start from a branch you want to measure (for example foo).
  2. Run:
pnpm bench:compare main foo

If you pass one branch, bench:compare automatically compares it to main.

Where outputs go

  • Summary report: benchmarking/compare/.results/report.txt
  • Raw benchmark numbers:
    • benchmarking/compare/.results/main.json
    • benchmarking/compare/.results/<your-branch>.json
  • CPU profiles (per benchmark, per branch):
    • benchmarking/compare/.profiles/main/*.cpuprofile
    • benchmarking/compare/.profiles/main/*.md
    • benchmarking/compare/.profiles/<your-branch>/*.cpuprofile
    • benchmarking/compare/.profiles/<your-branch>/*.md

The .md files are generated summaries of the CPU profile and are usually the fastest way to inspect hotspots.

Suggested investigation flow

  1. Open benchmarking/compare/.results/report.txt and identify largest regressions first.
  2. For each high-delta benchmark, compare:
    • benchmarking/compare/.profiles/main/<benchmark>.md
    • benchmarking/compare/.profiles/<branch>/<benchmark>.md
  3. Look for changes in self/inclusive hotspot share in runtime internals (runtime.js, reactivity/batch.js, reactivity/deriveds.js, reactivity/sources.js).
  4. Make one optimization change at a time, then re-run targeted benches before re-running full compare.

Fast benchmark loops

Run only selected reactivity benchmarks by substring:

pnpm bench kairo_mux kairo_deep kairo_broad kairo_triangle
pnpm bench repeated_deps sbench_create_signals mol_owned

Tests to run after perf changes

Runtime reactivity regressions are most likely in runes runtime tests:

pnpm test runtime-runes

Helpful script

For quick cpuprofile hotspot deltas between two branches:

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

This prints top function sample-share deltas for the selected benchmark.

Practical gotchas

  • bench:compare checks out branches while running. Avoid uncommitted changes (or stash them) so branch switching is safe.
  • Each bench:compare run rewrites benchmarking/compare/.results and benchmarking/compare/.profiles.

来自 sveltejs 的更多技能

performance-investigation
sveltejs
调查性能回退并寻找优化机会
official
svelte-code-writer
sveltejs
用于Svelte 5文档查询和代码分析的CLI工具,内置自动修复功能。三个核心命令:list-sections浏览可用文档,get-documentation获取特定主题的完整文档,svelte-autofixer分析代码并建议修复。自动修复器通过--svelte-version标志支持Svelte 4和5目标,通过--async选项支持异步模式。接受内联代码(含转义$字符)和文件路径进行分析。设计用于...
official
svelte-core-bestpractices
sveltejs
编写快速、健壮、现代Svelte代码的指南。在Svelte项目中,当被要求编写/编辑或分析Svelte组件或……时,请加载此技能。
official
svelte-code-writer
sveltejs
用于Svelte 5文档查找和代码分析的CLI工具。在创建、编辑或分析任何Svelte组件(.svelte)或Svelte…时,必须使用。
official
svelte-core-bestpractices
sveltejs
Guidance on writing fast, robust, modern Svelte code. Load this skill whenever in a Svelte project and asked to write/edit or analyze a Svelte component or…
official
scenario-writer
sveltejs
根据用户的描述选择一个要创建的新场景,将编写工作委托给 ai-scenario-writer 子代理并验证其正确性。
official
writing-opencode-plugins
sveltejs
OpenCode插件,@opencode-ai/plugin,@opencode-ai/plugin/tui,插件钩子,自定义工具,TUI路由,插槽,键位映射,以及打包。在创建时使用…
official
scenario-writer
sveltejs
根据用户的描述选择要创建的新场景,将其写作任务委托给 ai-scenario-writer 子代理,并验证其正确性。
official