diskEntry wrote a chunk's Latest as c.Latest.UnixNano(). For a chunk
without calls Latest is the zero time, whose UnixNano is out of int64's
range and is written as another time; readDiskEntry read it back as a
call on 1969-12-31. heatSplit and effortSplit count a chunk with a zero
Latest as recent, but one read back so as settled, so the settled set
after a build (14426 chunks on the real history) differed from the one
after a read (15677). The key heat-v1.json and effort-v1.json were
written under on a new version's first start missed on its second, and
the whole history was paired again: two cold peaks, not one.
A zero Latest is now written as 0 and read back as the zero time.
Old data: requests-v1.bin is rewritten under the new binary (its key
holds requestDiskBinary()), so nothing old is read by the new reader.
Run:
- TestDiskEntryKeepsNoLatest round-trips a zero Latest and
time.Unix(1790000100,5). Red on the old reader ("Latest 0001-01-01
... read back as 1969-12-31 16:00:00 -0800 PST"), green with the fix.
- Real history on mote (sandbox HOME, copy of the owner's sessions and
requests): the first start wrote heat-v1.json and effort-v1.json, the
second and third didn't rewrite them (both hit), and the heatmap's
JSON had the same md5 on all three starts.
- Rebased onto 244d80e23; at the pushed tree on mote:
go test -count=1 ./internal/usage ok (53.3s), gofmt clean,
go vet -tags nogui ./internal/usage for windows ok (linux, darwin ok
before the rebase, which touched no file of this commit).
Not tried: a full ./... suite.
After a cold start's first pages, nothing is held under GOGC 25 while
requestIndex.save writes requests-v1.bin, and the heap grew from 436 MB
to 764 MB before a collection, the footprint's peak. A heap profile
diffed from 13 s to 17 s gave save 444 MB of 465 MB allocated: each
entry grew its bytes from nil (appendDiskString 166 MB, the archive's
append 137 MB), and onDisk decoded every entry it had just written
with readDiskEntry, strings and all, to compare three fields (~95 MB).
Now toDisk hands diskEntry the last entry's bytes, onDisk reads the
size, mtime and archive with diskEntryArchive, which copies nothing,
and diskEntryPath gives bytes, looked up without a copy.
Measured on mote (M5 Pro), cold start with no caches, 390k calls,
a growing Codex rollout, 10 endpoints polled every 5 s, 60 s each:
- before (v0.1.2112): phys_footprint_peak 835 / 863 / 860 MB,
CPU 2:02.78–2:05.86
- after: 794 / 783 MB, CPU 2:01.55 / 2:01.12
- gctrace: between the first and second polls the heap now reaches
499 MB (live 470), where it reached 764.
Tests at this head, through mote-run:
- go vet -tags nogui ./internal/usage/ ./internal/gui/, GOOS linux,
windows and darwin: ok
- go test -timeout 45m ./internal/usage/: ok
- TestDiskEntryArchive (reads back what readDiskEntry reads, with zones
and actors, and no cut entry) and TestDiskEntryAllocatesOnce: pass.
With diskEntry's b set to nil again, TestDiskEntryAllocatesOnce is
red: "an entry on the last one's bytes allocated 5 times".