viaMagpie handed every caller its own copy of the options list it keeps
per stamp, and a window poll asks for it from most agents' fields and
pickers. In a real-account sandbox (abr.sh, 20 polls of drift, state and
providers on v0.1.2463) those copies were 33.7 MB of slices.Clone, plus
~8 MB more on the way, of the 713 MB the polls allocated.
viaMagpieShared returns the kept list itself, clipped, so an append
makes the caller's own array. The 58 callers that only read it, or
append onto it, now take it; viaMagpie (a copy) stays for the ones that
change it.
TestKeptListSharedWithoutACopy checks that 20 shared looks return the
kept array, and that an append onto a shared look and a write into
get's copy leave the kept list as it was.
Run on mote at this tree:
- gofmt, go vet (darwin, GOOS=windows, GOOS=linux with gateway),
go build ./...: ok.
- Broken by hand (shared returns slices.Clone): the test is red, "a
shared look copies the kept list".
- go test -count=1 ./internal/agent: ok (480s).
Not run: internal/gateway and internal/gui packages on this tree.