Files
magpie/internal
yetone b047cfe73c gateway: TestCRTidyTwentyFourMBLine bounds the bytes searched and allocated, not the wall clock (#5282)
The test is the relay hot path's bill for one 24 MB SSE line in 32 KB
reads. It had an 8s wall-clock bar. On main CI's Race step, beside heavy
shards, one_call_mended took 16.9s on ubuntu and 10.7s on macOS. Alone
under -race on mote it takes 4.4s. The bar measured the machine, and it
also missed one of the regressions it was there for: a copy of the held
bytes on every read took 0.37s.

crTidy now counts the bytes it searches for a line's end or the escape
(looked, one add per write and per region). The test bounds two things
the code controls, each against the line's size:
- bytes searched, at most 3x. Measured: 2x with no escape, 3x mended.
- bytes allocated (runtime.MemStats), at most 8x with no escape and
  40x mended. Measured: 5.4x (append grows the held line a quarter at
  a time), and mended 27x, 32x under -race (decoded into maps and said
  again).

Broken by hand, on mote:
- searching the whole held buffer for a line's end on each read (the
  quadratic read from yetone's review of #4256): 9.7 GB searched, red
  in both subtests.
- copying what is held on each read: 9.7 GB and 10.2 GB allocated, red
  in both subtests. The old 8s bar passed it at 0.37s and 0.77s.
Restored, green.

Run on mote at this head:
- go test -race -count=3 -run TestCRTidyTwentyFourMBLine ./internal/gateway:
  ok. mended takes 4.4s, no escape 0.19s.
- go test -race -run 'CR|Glm|GLM|Tidy' ./internal/gateway: ok.
- go vet ./internal/gateway on darwin, GOOS=linux and GOOS=windows: ok.
  gofmt -l: clean.

Not tried: a regression that searches without going through the
counted sites. The count bounds only what passes them. The allocation
bound still catches one that copies.
2026-11-05 03:41:57 +08:00
..
…
…
…
…
…
…
…
…