performance-investigation

bởi sveltejs

Điều tra suy giảm hiệu suất và tìm cơ hội tối ưu hóa

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.

Thêm skills từ sveltejs

svelte-code-writer
sveltejs
Công cụ CLI để tra cứu tài liệu Svelte 5 và phân tích mã với trình tự sửa lỗi tích hợp. Ba lệnh chính: list-sections để duyệt tài liệu có sẵn, get-documentation để lấy tài liệu đầy đủ cho các chủ đề cụ thể, và svelte-autofixer để phân tích mã và đề xuất sửa lỗi. Trình tự sửa lỗi hỗ trợ nhắm mục tiêu Svelte 4 và 5 qua cờ --svelte-version và chế độ async qua tùy chọn --async. Chấp nhận cả mã nội tuyến (với ký tự $ được thoát) và đường dẫn tệp để phân tích. Được thiết kế để sử dụng trong...
official
svelte-core-bestpractices
sveltejs
Hướng dẫn viết mã Svelte nhanh, mạnh mẽ, hiện đại. Tải kỹ năng này bất cứ khi nào đang trong dự án Svelte và được yêu cầu viết/chỉnh sửa hoặc phân tích một thành phần Svelte hoặc…
official
svelte-code-writer
sveltejs
Công cụ CLI để tra cứu tài liệu Svelte 5 và phân tích mã. PHẢI được sử dụng khi tạo, chỉnh sửa hoặc phân tích bất kỳ thành phần Svelte (.svelte) hoặc 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
Chọn một kịch bản mới để tạo dựa trên mô tả của người dùng, giao việc viết kịch bản cho tiểu tác nhân ai-scenario-writer và xác minh tính chính xác.
official
performance-investigation
sveltejs
Điều tra các vấn đề suy giảm hiệu suất và tìm cơ hội tối ưu hóa
official
writing-opencode-plugins
sveltejs
Plugin OpenCode, @opencode-ai/plugin, @opencode-ai/plugin/tui, hook plugin, công cụ tùy chỉnh, tuyến TUI, slot, keymap và đóng gói. Sử dụng khi tạo,…
official
scenario-writer
sveltejs
Chọn một kịch bản mới để tạo dựa trên mô tả của người dùng, ủy quyền viết kịch bản đó cho tiểu tác nhân ai-scenario-writer và xác minh tính chính xác.
official