Files
magpie/internal/filememo
yetone f99b227c27 filememo: a parse is kept under a struct key, not a joined string
read joined kind + "\x00" + path into a new string for every read,
and Look scanned every key with HasSuffix of another joined string.
A read is asked for each model of each provider a poll lists, so the
keys alone were 33 MB of what twenty window polls allocated with
real accounts (m2463 profile). seen is now keyed by
memoKey{kind, path}; a held read and Look allocate nothing.

Test: TestHeldReadAndLookAllocateNothing. 50 files in a long folder,
under Hold: AllocsPerRun of a read found unchanged is 0, and of Look
0; a write then Look reads the new value.

Run on mote, at this tree on 88372a39d:
- gofmt, go vet (darwin, windows, linux): ok
- the new test alone: ok
- broken by hand (the old filememo.go back): red, "a held read of a
  file found unchanged allocated 1 times, want 0"
- go test ./internal/filememo ./internal/settings ./internal/catalog
  ./internal/provider ./internal/agent: all ok

Not run: an A/B with the real-account sandbox for this change alone.
2026-11-01 04:50:29 +08:00
..
windows: an account list read while another magpie writes it is waited for, not taken for no accounts (Packing1 on Discord, Windows 11: 早上更新重启后之前登录的Antigravity订阅供应商和账号都没了 … 整行都没了,供应商里面antigravity直接消失了) — on Windows a file being renamed over (every write magpie makes: a temp file renamed onto it) is, for a moment of up to ~2ms, "The system cannot find the file specified" to anyone else looking at it, with MoveFileEx and with POSIX-semantics renames alike. filememo.Read gave that back as an error, readLogins as no accounts, and whatever change came next (any account's read-modify-write) wrote the empty list back: every built-in account gone, its subscription with it. Measured on Windows 11 (10.0.0.132): one process replacing a 200 KB file, another stat-ing and reading it, saw the file "not there" in a few windows each 20 s. Now steady.Stat and steady.ReadThere wait out a moment of a file not there (15 tries a millisecond apart, Windows only), and filememo looks through them, remembering a file found not there so one that really isn't costs the wait once. A magpie started by an update now waits for the one it replaces before its start-up moves write any file (AwaitPredecessor at the top of run, not only in the GUI). TestLoginsKeptWhileAnotherMagpieWrites (Windows: two writers replacing logins.json, readLogins never without the Antigravity account) failed 1 in 3 and 2 in 8 runs on the old code ("read as no accounts 8 times"), passed 11 of 11 on this; filememo's TestReadWhileReplaced the same (1180 misses on the old code); TestStatWaitsOutAReplace everywhere. A real update in a sandbox home on the Windows box, magpie-cli 0.1.880 → 0.1.942 from the release, kept the account and logins.json byte for byte. go vet (darwin, and windows nogui), builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
2026-10-05 10:57:45 +08:00