limoni-performance
Skill151 starsChanged 3 months agoApache-2.0View on GitHub
Where allocations hide in a Limoni frame, how to find them, how to compare benchmarks honestly, and the release and CI checks that catch what one machine cannot. Load before touching a Draw path, a benchmark, an allocation test, or before cutting a release.
- Installs packages
- Commits and pushes
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- limoni_developmentSkill
- limoni-agent-surfaceSkill
- limoni-text-renderingSkill
- limoni-zestSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
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
- Very specific: line 14
Every one of these was found in this repository, each after the widget benchmarks said 0 B/op:
- Distinctive: line 67
Check numbers against each other.
- Very specific: line 94
Verify from outside the repository: go install github.com/thebanri/limoni/cmd/zest@vX.Y.Z in an empty directory.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
Allocations, measurement, releases
The headline claim is a number — zero heap allocations per frame — so the rule is simple: measure the program people run, on more than one operating system, and distrust a number you like.
Where allocations hide
Every one of these was found in this repository, each after the widget
benchmarks said 0 B/op:
| Hiding place | What it looked like | Fix |
A closure built in Draw | ctx.RegisterClick(area, func(){...}) per clickable widget per frame | cell.ClickAction{Focus: id, Toggle: &b} / RegisterScroll: data, copied into a slice the frame reuses |
| The frame wrapping handlers | RegisterClick wrapped each func() in a func(ev) | store the handler as it is |
| A theme closure | ctx.ThemeStyle = func(role)... per widget per frame | build once on the frame |
| A captured local escaping | visibleCount captured by a mouse closure escaped even when no closure was registered | copy it inside the if that registers |
| String building | prefix + label, icon + " ", fmt.Sprintf in a draw | write the parts separately with SetStringWithin |
sync.Pool | every GC empties it, so the next frame allocated a scratch and two maps | keep scratch on the widget's state |
os.Getenv on Windows | graphics.DetectProtocol() per frame: ~12 env reads, 21 allocations on Windows only | detect once, keep it in CapabilityProfile |
| Interface boxing by the caller | RenderWidget(widgets.Checkbox{...}) copies the struct to the heap | hold widgets by pointer |
| A struct growing past 128 bytes | one bool added to the end of cell.Context → 144 B/op in every widget with a fallback click closure | keep Context ≤ 128 bytes; put new fields in an existing padding hole |
The 128-byte cliff. A closure captures a variable by value only while it
is small; above 128 bytes the compiler captures by reference, which moves the
variable to the heap. cell.Context is passed to every Draw and captured by
the fallback click closures, so one extra field at the end of it turned every
widget from 0 B/op to 144 B/op — while the code around it was unchanged.
go build -gcflags=-m says which it is: leaking param: ctx is free,
moved to heap: ctx is an allocation per call. TestContextStaysUnder128Bytes
guards the size; new fields go in the padding after Style.
Finding them
// Deterministic: force a GC each iteration, or a sync.Pool refill looks flaky.
if a := testing.AllocsPerRun(50, func() { draw(); runtime.GC() }); a != 0 { ... }go test ./pkg -run '^$' -bench X -benchmem -memprofile mem.out -memprofilerate 1 -o pkg.test
go tool pprof -sample_index=alloc_objects -top -lines pkg.test mem.out # names the lineAllocsPerRun returns an average: a reading of 1 means every iteration
allocated, not one stray. Treat it as a fact about the program, not as flakiness.
Benchmarks that only call Draw cannot see registration. BenchmarkInteractiveFrame
(in benchmarks/) draws through a real Terminal with a theme; keep new
interactive work covered by it, and CI gates every widget benchmark.
Comparing honestly
git worktree add --detach /tmp/base <base-commit>
(cd /tmp/base && go test ./core/buffer -run '^$' -bench X -count=5)
go test ./core/buffer -run '^$' -bench X -count=5 # same machine, same sitting
git worktree remove /tmp/base- Compare against the previous commit, never against the README's numbers.
- Check numbers against each other. A load time that contradicts the per-item cost, or a line count that contradicts the elapsed time, means the harness is wrong — a "30 s" load turned out to be a leftover process from a failed run.
- The order of a condition matters in a per-cell loop:
cell.IsCluster(c) && !opts.ClusterWidthscosts nothing; the reverse cost 5% onBenchmarkDiff_FullChanges. - Kill stray processes by pid file.
pkill -f <pattern>matches the shell running it and kills your own session.
What only CI can tell you
Windows is the runner that catches what Linux hides: os.Getenv allocating, and
AF_UNIX resetting a connection closed with unread data. Cross-compiling
(GOOS=windows go vet ./...) proves it builds, nothing more. Push and read the
job.
Releasing
go build ./... && go vet ./... && go test ./...,-raceon the CLAUDE.md list, the two benchmark gates,GOOS=js GOARCH=wasmbuild.gorelease -base=<previous tag>without-version: naming a version that does not exist yet makes the Go proxy cache a "not found" for it, andgo install pkg@versionthen fails for ~18 minutes.- In a worktree of
origin/main: turn## [Unreleased]into the version with today's date, add the compare link, commitrelease: vX.Y.Z, push, tag, push the tag. gh release createwith notes assembled from that CHANGELOG section.- Verify from outside the repository:
go install github.com/thebanri/limoni/cmd/zest@vX.Y.Zin an empty directory. The proxy's@latestlist lags the tag by a few minutes; the version itself is usually available at once.
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.

