A catalog sync asked about each agent's files many times a round
(GetJSON, GetTOMLTop, settings.load from each agent's Sync): on Windows
an empty sandbox's start stat'ed settings.json 1065 times and
config.toml 569 in 25s, almost all from SyncCatalog. Each round now
holds what was read (filememo.Hold), as the GUI's read-only requests and
the gateway already do.
What a hold serves may be up to a second old, so nothing is written from
it any more:
- edit.Read, which every Set*/Del* helper and the agents' own
read-modify-write code start from, looks at the disk even under a
hold (filememo.ReadNow). The getters (GetJSON, GetJSONRaw,
GetJSONItem, GetEnvFile, GetYAMLTop, the YAML getters, GetTOMLTop's
line reader) read through the hold.
- settings: a write's load under fileMu (lockFile) reads the disk too.
Before this, a GUI request's hold could already hand a Set* stale
bytes; that is closed as well.
WriteAtomic forgot every held file even when it left the file as it
was, and a sync writes each agent's files each round, almost always
unchanged: it now forgets only after a real write.
Measured on xiaomi-gpu (Windows 11), as in the steady commit before
this one (second start, 27s, stats counted by an uncommitted build):
before 2307 stats, sync 1318 of them, round 1308ms
this alone 1787 stats, sync 864, round 1273ms
with steady's 988 stats, sync 96, round 96ms
First start of an empty sandbox: 2448 stats before, 1041 after.
Run:
- TestHeldReadIsNotWhatAWriteIsMadeFrom (json, toml, yaml),
TestUnchangedWriteKeepsWhatIsHeld, TestHeldSettingsAreNotWhatAWriteIsMadeFrom:
with edit.Read and the settings write load put back on the held read
and WriteAtomic's Forget removed by hand, json and yaml lost the other
app's key, the settings case wrote "light" over "dark", and the
forget case went red; green with the change, on mote.
- mote, at the pushed head: gofmt -l internal clean; GOOS=linux/windows/
darwin go vet of steady, edit, filememo, settings and agent clean;
go test -count=1 of steady, edit, filememo, settings, agent, provider,
catalog and library ok; internal/gui red only on TestMainWindowCorners
(#3949, macOS 27, red on main before this).
- xiaomi-gpu: go test of edit, filememo and settings ok.