.agents/skills/rspack-perf/SKILL.md
Optimize from the shape of Rspack's data. Always consider the rough cardinality of internal structures before changing an algorithm:
dependency/export_info > module/exports_info/module_graph_module > chunk > chunk_group > entry/runtime.
The larger the structure, the more dangerous full scans, repeated traversals, broad cloning, eager materialization, and per-item allocation become. Avoid whole-graph or whole-compilation work on high-cardinality structures unless profiling proves it is necessary.
rayon for CPU-bound synchronous work, use rspack_parallel abstractions for async orchestration, and avoid mixing rayon and tokio pools inside one workflow without a clear boundary.format!, .to_string(), and owned-string construction for identifiers, requests, resource names, runtime helpers, export names, and module ids.&str, interned strings, Atom, Arc<str>, or cached rendered strings where ownership is not required.Arc when ownership must cross phases.Vec, HashMap, HashSet, IndexMap, or combination lists inside high-cardinality loops.collect() followed by one traversal.FxHashMap/FxHashSet or identity hashing for interned or already-hashed keys.Vec plus stable indexes for dense key spaces.Functional validation:
pnpm run build:cli:dev before pnpm run test:unit.pnpm run test:unit after the optimization.Performance validation:
compilation stages case that directly covers the optimized feature.Before submitting:
pnpm run format:rs.pnpm run format:js.cargo clippy --workspace --all-targets --all-features.After the optimization is complete, ask the user whether they want to create a PR.
If the user wants a PR:
perf/.perf(<scope>): <summary> or perf: <summary>.perf: .Validation section in the PR body.gh workflow run 'Ecosystem Benchmark' -f pr=<pr-number>
gh run list --workflow 'Ecosystem Benchmark' --limit 5
Use the PR number as the workflow input. A run on main does not benchmark the PR branch.
If the user allows waiting for GitHub CI: