A file whose time is under two seconds old is read again on every read
and compared with the bytes parsed, since a second write inside a clock
tick can leave the same time and size. Each of those reads made a new
buffer. As magpie starts, Codex's sync writes ~/.codex/config.toml, and
every read of it for the next two seconds made one. With the owner's
real 1.45 MB config.toml, v0.1.2432's startup profile has
readCodexStoreSetting reading it ~155 times (226 MB) and the TOML table
spans ~89 times (129 MB). That is 381 MB of the 1.37 GB allocated before
the window's first poll, and the peak RSS with it.
Now a read that finds the same size and time reads into a buffer kept on
the entry while its bytes are, and gives the buffer back when they
match. A read beside it takes the buffer out first, so it reads into one
of its own. Bytes that differ are parsed from that read's buffer, which
no one else has. Nothing changes in what is looked at: the file is still
read and compared each time until it settles.
steady.ReadThereInto is ReadThere into a caller's buffer.
TestRecentFileReadAgainIntoOneBuffer (a 1.2 MB file stamped now): 20
reads allocate under a quarter of the file each, it is parsed once, 8
readers at once each get the right length, and a write of the same size
and time is seen and kept as its own bytes. Broken by hand on mote, with
the buffered path off, it is red (1191002 bytes a read).
Run at 8ce36a0ef (on d714c4216), on mote: gofmt clean; filememo, steady,
provider (146s) and agent (300s) ok. gateway: TestBurstTellsNoSpeed red
(#2719, under load, no file read on its path). gui:
TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red on main) and
TestMainWindowCorners (#3949, macOS 27). vet ok on darwin, linux and
windows. Windows: filememo and steady ok. WSL: filememo, steady,
provider and gateway ok; agent's 6 reds are the same on origin/main
80bcef18f (#4033, #3548).