Optimize measured performance
Run xpd optimize to find repeated calls, loop-invariant work, linear scans, and oversized intermediates, then prove each speedup against real project workloads with --bench and profiler adapters.
Survey static waste and measure hotspots
Section titled “Survey static waste and measure hotspots”Run a static scan first to locate mechanical performance waste without executing code.
xpd optimize src/xpd optimize src/ --since HEAD~1 --format jsonAdd --bench to time a representative command at start and at every gate, or pass --adapter perf.py (defining workloads() returning named zero-argument callables) so functions consuming at least 5 percent of workload CPU time enter the performance checklist automatically.
| Input | What it measures |
|---|---|
| Static survey | rule-issue, repeated-call, repeated-mask, redundant-key-check, loop-invariant-call, matrix-reduced, materialized-for-one, linear-scan-in-loop |
--bench "<command>" |
Median, minimum, and maximum wall-clock duration across commits on the same machine class |
--adapter perf.py |
Per-function CPU share, call counts, and peak memory bytes for hotspot checklist items |
Run a recorded optimize ledger
Section titled “Run a recorded optimize ledger”- Start from a clean commit with
xpd optimize start src/ --check "<project-check>" --bench "<workload>"(or--adapter perf.py).startrequires--benchor--adapter. - Inspect findings and hotspots with
xpd optimize src/ --format jsonand track active runs withxpd optimize status --format json. - Write
plan.jsonciting finding IDs or fix goals (faster,both, ordesign) and submit it withxpd optimize plan plan.json. - Commit one optimization at a time and gate it with
xpd optimize gate <fix-id>. With--bench, every fix must cut median time by at least 2% with non-overlapping intervals (after.max_ms < before.min_ms). With--adapter, each workload is judged on its own: none may regress, and at least one must show that speedup, so a large workload cannot hide a change in a small one. For data pipeline rewrites, confirm identical output withxpd equiv. - Close the run with
xpd optimize finishonce no fix is open. Arepeated-callorrepeated-maskfinding must be fixed or accepted with a reason. Every other finding is advice that no run has to clear.
See xpd optimize for all flags and adapter schemas.