agentleFS
flooooooooooowflooooooooooow/flow-skills/skills/flow-perf/SKILL.md

flow-perf

Skill1 starsChanged 3 months agoMITView on GitHub

Measure and improve the performance of a Flow program. Use for benchmarking, profiling, "make it faster", comparing backends, SIMD, GPU offload, or any claim about speed.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Remove allocation and copying from the inner loop.

    line 47
  2. Distinctive:

    Check the generated C for something obviously silly, such as a bounds check that cannot fail or a struct copied by value in a loop.

    line 48
  3. Distinctive:

    Only then reach for SIMD or GPU, and measure the transfer cost as well as the kernel.

    line 51
  4. Distinctive:

    Make sure the result is used, or the compiler will delete the work.

    line 67
  5. Distinctive:

    Run the baseline and the change on the same machine in the same session.

    line 70

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Performance

Measure first. A performance claim without a method behind it is not a result.

Measure

ls benchmarks/
python3 scripts/run_bench.py --help
bash scripts/bench.sh
flow test-matmul                 # matmul demo plus assembly

Report every time: the machine, the operating system, the compiler and its version, the Flow host, the backend, the optimisation flags, the input size, the number of repetitions, and the spread across runs. A single timing on a laptop that was also compiling something is noise.

The routes

RouteCommandWhen
C backenddefaultBaseline. Portable, no LLVM
MLIR--backend=mlirOptimisation passes, tensor work
JITflow jit program.flowFastest start-to-answer for a hot loop
GPUflow gpu program.flowData-parallel kernels, emitted as Metal
SIMDlib/stdlib/audio/simd.flow, tools/simd/Vectorised inner loops
FLOW_HOST=python flow mlir program.flow --optimize
FLOW_HOST=python flow mlir-run program.flow
FLOW_HOST=python flow fir-g program.flow --opts     # FIR-G graph and analyses

fir-g dumps the graph and its analyses, with --calibrate and --opts. Use it to see what the optimiser knows before guessing at a change.

Order of attack

  1. Confirm the hot spot with a measurement. Do not optimise from intuition.
  2. Fix the algorithm. A better method beats every flag.
  3. Remove allocation and copying from the inner loop.
  4. Check the generated C for something obviously silly, such as a bounds check that cannot fail or a struct copied by value in a loop.
  5. Try the other backend and measure both.
  6. Only then reach for SIMD or GPU, and measure the transfer cost as well as the kernel.

Read the generated C

FLOW_HOST=python flow compile program.flow
cat "$FLOW_HOME/build/program.c"

This is the honest account of what a construct costs. If a declarative form lowers badly, that is a compiler issue worth filing rather than a reason to hand-write the loop everywhere.

Guard against measuring nothing

  • Make sure the result is used, or the compiler will delete the work.
  • Warm up before timing.
  • Time enough iterations that the clock resolution stops mattering.
  • Run the baseline and the change on the same machine in the same session.
  • Report the spread, not just the best run.

Reporting

Say what got faster, by how much, on what, and what did not change. Label estimates as estimates. If you only ran the benchmark once, say so.

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.