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 的更多技能

svelte-code-writer
sveltejs
Svelte 5 文件查詢與程式碼分析的 CLI 工具,內建自動修復功能。三個核心指令:list-sections 瀏覽可用文件、get-documentation 取得特定主題的完整文件、svelte-autofixer 分析程式碼並建議修復。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
performance-investigation
sveltejs
調查效能回歸並尋找最佳化的機會
official
writing-opencode-plugins
sveltejs
OpenCode 插件、@opencode-ai/plugin、@opencode-ai/plugin/tui、插件鉤子、自訂工具、TUI 路由、插槽、按鍵映射與封裝。用於建立、…
official
scenario-writer
sveltejs
根據用戶的描述選擇一個新的場景來創作,將其寫作任務委派給 ai-scenario-writer 子代理,並驗證其正確性。
official