A cold build (first start, or after an update that changes internal/usage)
kept every chunk's archive on the heap until save had written
requests-v1.bin and swapped them for the file's pages: 31MB for 15.7k
sessions, the largest thing a cold peak held over a warm start's.
Now a build that wants requestDiskLeast or more files written writes each
archive to requests-*.spill as the chunk is made, lets go of the heap copy,
and maps the file once the build is done (unlinked at once). save then
swaps the spill's pages for requests-v1.bin's as before: pagesRank orders
heap < spill < file, and keep and save take the later. A spill that can't
be written or mapped has each of its chunks made again from its source, so
none is left without an archive. Windows maps no file, so nothing changes
there.
Run, real data (15.7k Claude Code + Codex sessions, sandbox HOME, copies of
the call shards, requests-v1.bin removed before each run), the gui warm-up
harness alternating old (cbbf3163c) and new, 4 rounds each:
phys_footprint_peak old 396 353 346 352 MB, new 319 322 329 329 MB
peak live (gctrace) old 209-259 MB, new 188-205 MB
at rest unchanged (184-205 MB), warm-up time in the same range.
gctrace: cold max live after mark is now 187MB against warm's 173MB; what
is left of the gap is allocation churn (1.2GB allocated in the cold
build against 280MB warm), not held data.
go test ./internal/usage ./internal/gui ok; -race -count=3 of the disk and
spill tests ok; GOOS=linux and windows go vet -tags nogui ok; gofmt clean.
Broken by hand: no spill put -> TestRequestDiskBuildSpills red; done not
making a chunk again -> TestArchiveSpillFailedMadeAgain red; the spill
ranked as the file -> TestRequestDiskBuildSpills red after the save.
Not tried: Windows (no mapping, path unchanged), a disk that fills while
spilling (the made-again path is covered by the unit test only).
12 lines
310 B
Go
12 lines
310 B
Go
//go:build !unix
|
|
|
|
package usage
|
|
|
|
// mapDiskFile maps nothing: on Windows a file mapped can't be renamed over,
|
|
// and toDisk replaces the file so. The file is read into memory instead.
|
|
const mapsFiles = false
|
|
|
|
func mapDiskFile(string) (*diskMapping, bool) { return nil, false }
|
|
|
|
func (m *diskMapping) read() {}
|