agentleFS
ychampionychampion/ystack/skills/perf-loop/SKILL.md

perf-loop

Skill4 starsChanged 2 days agoMITView on GitHub

Make code faster by measurement, not by guess: set a target, build a repeatable benchmark, profile to find where time or memory really goes, change one thing at a time, keep a table of numbers, and keep only changes that beat the noise. Use for "make this faster", "why is this slow", "optimize", "reduce memory", "speed up the build/tests/query", or a performance regression.

8 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use addskill, apply-firmware and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ryanportfolioSkill

    addskill

    Create, import, update, or install repo or personal skills: runtime ownership, resources, discovery checks.

    Also in 5 projects that use this

  • ryanportfolioSkill

    apply-firmware

    Bring current folder (plain folder, existing repo, old or partial firmware copy) up to full Harness Firmware in place. Mirror external repo → adopt-repo.

    Also in 5 projects that use this

  • +10 more from ryanportfolio

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write what is measured and what counts as done: "p95 of GET /search under 200 ms on the fixture data", "build under 60 s", "peak memory …

    line 27
  2. Very specific:

    Use a real profiler for the stack (a CPU or sampling profiler, a flame graph, the database's query plan via EXPLAIN ANALYZE, a heap …

    line 41
  3. Distinctive:

    Run the benchmark and the tests.

    line 53
  4. Distinctive:

    Keep a change only if it beats the noise and the tests pass.

    line 62
  5. Distinctive:

    No optimization without a number before and after.

    line 72

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Perf loop

Most guesses about where time goes are wrong. Measure, change one thing, measure again, keep the numbers.

When it applies

  • Something is too slow or too memory-hungry and there is a number that would count as fixed.
  • A regression: it got slower between two versions (for that, bisect it with the benchmark as the test; see step 2).

Skip it for code that runs once and already finishes in a time nobody minds.

Procedure

1. Set the target

Write what is measured and what counts as done: "p95 of GET /search under 200 ms on the fixture data", "build under 60 s", "peak memory under 1 GB". No target, no stopping point.

2. Build the benchmark

One command that runs the slow path on realistic input and prints the number. Make it repeatable: same data, warm-up runs discarded, other load off the machine, at least 5 runs. Record the median and the spread. The spread is the noise: a later change must beat it to count.

For a regression, the benchmark plus a threshold is a pass/fail command, so git bisect run can find the commit.

3. Profile before changing anything

Use a real profiler for the stack (a CPU or sampling profiler, a flame graph, the database's query plan via EXPLAIN ANALYZE, a heap snapshot, the build tool's timing report). Write down the top 3 hot spots with their share of the total. Optimizing something that takes 2% can save at most 2%.

4. Change one thing

Pick the biggest hot spot. Typical wins, in rough order of payoff: do less work (cache, skip, batch, remove an N+1 query, add an index), a better algorithm or data structure, less allocation or copying, then parallelism. Make one change.

5. Measure and record

Run the benchmark and the tests. Add a row:

| # | Change                         | Median  | Spread | vs base | Tests | Kept |
| 0 | baseline                       | 840 ms  | ±30    | -       | pass  | -    |
| 1 | index on orders.user_id        | 310 ms  | ±12    | -63%    | pass  | yes  |
| 2 | memoize price lookup           | 305 ms  | ±15    | -1%     | pass  | no (noise) |

Keep a change only if it beats the noise and the tests pass. Revert the rest; they are complexity with no payoff.

6. Repeat or stop

Re-profile after each kept change: the hot spots move. Stop at the target, or when the top hot spot is something you can't change (network, disk, an external service), and say so.

Rules

  • No optimization without a number before and after.
  • One change per measurement.
  • Correctness first: tests pass on every kept row.
  • Report the table, the target, and whether it was met.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.