TestCappedIsSmall red: one HeapAlloc delta measured capped at 12,056 vs bounded 82,624 (6.9x, wants 10x)
TestCappedIsSmall (internal/capre) failed in a full go test -count=1 -timeout 45m ./... run on the Linux box (wsl-run, magpie-desktop) at 2fbead798 (v0.1.3570):
--- FAIL: TestCappedIsSmall (0.05s)
capre_test.go:59: held to a length: 12056 bytes, bounded 82624
FAIL github.com/yetone/magpie/internal/capre 0.064s
The test measures runtime.MemStats.HeapAlloc before and after one MustCompile and wants the capped program to be under a tenth of the bounded one. Here capped measured 12,056 bytes (6.9x smaller, not 10x). A HeapAlloc delta counts whatever else the runtime allocated between the two reads (other goroutines, the testing framework, GC timing), so the capped side, being small, is the one noise moves. Suggest measuring something the program owns (e.g. testing.AllocsPerRun/testing.Benchmark bytes per op over many compiles, or the compiled program's instruction count) instead of one heap delta.
Not taken by me (found after the CRS fix's tag; the change doesn't touch capre).
I'll take this one.
One HeapAlloc difference also counts what else was allocated or freed between the reads: on this box the test alone at main was red 10 of 10, the bounded side reading ~11.5kB where a bounded program holds ~92kB, and a second GC before the first read brought it back to ~92kB. The test now reads after two GCs and over 100 copies of each program, which gives a steady ~1.3kB vs ~92kB, over 70x apart against the 10x it wants, and stays green with 64kB from another goroutine injected between the reads: fix/5975-capre-alloc (351297a2 on db0f2f20). I kept it measuring held heap rather than AllocsPerRun or bytes per op, since those count what a compile allocates, not what stays, and the instruction count isn't reachable from outside regexp; the reason is in the body. Green 20 of 20, red 7 of 10 with the old measurement put back, not tried on a Mac, Windows or your WSL box. Details in the commit body.
The full suite with this and my five other patches from today stacked on db0f2f20 (tree eecf5b88): 89 packages ok, red only in filed ones (#5238, #5993, #5995, #5239). git format-patch --no-signature --full-index --stdout db0f2f20..351297a2 | sha256sum is e946051dddab959d73d94576cdbee8ba22a82ac564fdc9faf6c09ea69d9afed5.
Seen again in a full go test -tags nogui -count=1 ./... on WSL magpie-desktop (Go 1.26.8) at f33965719 (origin/main 410d4e5f2 plus a gateway-only change): capre_test.go:59: held to a length: 18032 bytes, bounded 88056 (4.9x). Not taking it; the change under test doesn't touch internal/capre.