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.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- flow-audioSkill
- flow-autodiffSkill
- flow-basicsSkill
- flow-compiler-devSkill
- flow-debugSkill
- flow-dynamicsSkill
- flow-effectsSkill
- flow-graphicsSkill
- flow-setupSkill
- flow-stdlibSkill
- flow-verifySkill
- flow-wasmSkill
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
- Distinctive: line 47
Remove allocation and copying from the inner loop.
- Distinctive: line 48
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.
- Distinctive: line 51
Only then reach for SIMD or GPU, and measure the transfer cost as well as the kernel.
- Distinctive: line 67
Make sure the result is used, or the compiler will delete the work.
- Distinctive: line 70
Run the baseline and the change on the same machine in the same session.
≈ “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.
Files
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 assemblyReport 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
| Route | Command | When |
| C backend | default | Baseline. Portable, no LLVM |
| MLIR | --backend=mlir | Optimisation passes, tensor work |
| JIT | flow jit program.flow | Fastest start-to-answer for a hot loop |
| GPU | flow gpu program.flow | Data-parallel kernels, emitted as Metal |
| SIMD | lib/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 analysesfir-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
- Confirm the hot spot with a measurement. Do not optimise from intuition.
- Fix the algorithm. A better method beats every flag.
- Remove allocation and copying from the inner loop.
- 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.
- Try the other backend and measure both.
- 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.
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
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.

