36200091a (Niko-Wu's patch from #2219, picked as written) bounds the
8 MB parse by 8 times the 2 MB one, 2x room on each side of the linear
4x and the quadratic 16x. On mote at load 250 it went red 1 run in 13:
load didn't slow both parses alike. The sizes are now 1 MB and 8 MB, so
linear is 8x and quadratic 64x, and the bound of 24 leaves about 3x on
each side; each size keeps the fastest of five parses.
Run on mote (macOS 27), at this tree:
- go test -tags nogui -count=30 -run TestTOMLBigFile ./internal/edit at
load 214: ok.
- Broken by hand, tomlShaper's line found by a scan from the top of the
file (the per-key pass 2a4042a9 removed): red, "an 8 MB file took
1m52.9s to parse, 71.4x the 1 MB one's 1.58s". Reverted.
- gofmt -l clean.
Still a timing test: it measures a ratio, not a count, since the parse
has no counter to read without adding one to toml.go.
edussss on 10-15, running `go test -tags nogui ./...` for #1928 at load
average ~190: TestTOMLBigFileParsesInLinearTime went red, a 3 MB file
took 1.272s against the 1s bound. Rerun alone it passes. The parse was
still linear; the bound was not.
The check now parses a 2 MB and an 8 MB file three times each, keeps
the fastest of each, and requires the 8 MB time to stay under 8 times
the 2 MB one. Load slows both parses together, so their ratio holds
where a wall-clock second does not. The code standards' "a timing test
leaves room on both sides" asked for exactly this: measured here, the
linear parse's ratio is 3.7 to 4.5, and the quadratic parse the test
guards against, which counts each key's line from the top of the file,
needs 16 times the time for the 4 times bigger file. 8 sits between
the two, far from both.
What was run:
- go test -tags nogui ./internal/edit/: ok
- the fixed test with -count=3: ok (6 runs)
- a local quadratic tomlShaper (per-key line scan, the behavior
2a4042a9 removed): the ratio reads 16.0x (2 MB 5.3s, 8 MB 1m25s)
and the test goes red; reverted after
- gofmt -l internal/edit/: empty
- go vet -tags nogui ./internal/edit/ at GOOS=windows and GOOS=linux
(the latter CGO_ENABLED=0; the local macOS SDK has no glibc, so the
cgo path of a dependency cannot be vetted here): clean
No .github/, site/ or go.mod/go.sum file is touched.
Co-Authored-By: Claude Code <noreply@anthropic.com>