ac4af582301a4e8a29245dbba767eba31334ddf9
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
62a1dcdd79 |
usage: a start's log blocks are of log-v1.bin's pages, not the heap (#2278)
logDiskRead read log-v1.bin whole with os.ReadFile, and the kept blocks' Archives were slices of that copy, so a 240k-call history held ~7 MB of file bytes in the heap for good. GOGC then let the heap grow by about as much again. Where the system maps the file, the blocks are now of its pages, the same way requests-v1.bin's blocks already are (diskMapping, readMapped, m.read()). Elsewhere it is read into the heap as before. Run at the pushed head, on mote, through mote-run: - go vet ./internal/usage: ok. GOOS=linux and GOOS=windows go vet ./internal/usage: ok. - go test ./internal/usage: ok. go test ./internal/usageapi: ok. - New TestLogDiskBlocksMapped: 2 full blocks plus a tail are written, the log is restarted and read again, and each full block's Archive must be inside the mapping. Broken by hand (c.mapped = m dropped): red, "block 0: read from the file into the heap". Green again restored. - go test ./internal/gui: FAIL on the AppKit window tests only (TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt, TestMainWindowCorners and 7 others), killed at their deadline on mote under load ~24. These are #4125 and #2645, and the same tests fail without this change. Bench on mote, with the real 240k-row history: a warm restart while the Sessions tab polls, and the heap profiled at 200 s. - In use: 174.1 and 175.0 MB with this change, 187.6 MB without. - Footprint at 200 s: 290 and 297 MB with it, 297 MB without. mote's load (~24) makes this ±20 MB, so the footprint gain is not resolved. Not tried: Windows, where the file is still read into the heap. |
||
|
|
9dc7d6eb84 |
usage: a large build's archives are held in a spill file as they are made (#3493)
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 (
|
||
|
|
cbbf3163cb |
usage: a cold build's chunks are of the file's pages once it is written (#3493)
A start that reads requests-v1.bin keeps each chunk's archive in the
file's mapped pages, not on the heap. A start that builds the chunks
(a cold one: no file, or one of another build) kept the archives it
encoded on the heap until the next start, after writing the very same
bytes to the file: 32-40MB for 15.7k sessions, and a resting heap
~50MB over a warm start's.
Once save has written the file, onDisk maps it and makes, for each
chunk whose archive is of the heap, a copy whose archive is the same
bytes of the mapping (checked equal). save swaps it in for the chunk
of the same serial: a read since has copied the chunk with a use of
its own, so the pointer it wrote is gone by then. A read that copied
the chunks before the swap and finishes after it keeps the mapped
archive (keep), or it would put the heap one back. Nothing changes
where no file is mapped (Windows).
diskUnmapped, the tests' hook, is an atomic.Pointer: a mapping's
cleanup reads it on its own goroutine while the next test sets it,
which -race -count=4 caught once the new test let go of mappings.
Run at this tree (
|
||
|
|
115ca34343 |
usage: the chunks' file is mapped, not read into the heap (#3493)
A start read requests-v1.bin's 44MB of chunk archives into the heap,
where they stayed: a fifth of the heap at rest, and with GOGC 25 a
larger heap goal through every warm-up step. They are pointer-free and
only ever decoded, so on unix the file is now mapped read-only
(MAP_SHARED, PROT_READ) and each chunk's Archive is a capped slice of
the mapping. A cleanup unmaps it once no chunk refers to it. The file is
only replaced by a rename (toDisk), never written in place; a read past
its end, if another program cut it short, is caught by readMapped
(SetPanicOnFault) as a failed read, not a crash: the chunk unpacks as
nil and reads as no rows, as a corrupt archive did before, until its
session file changes or magpie starts again. Windows can't
rename over a mapped file, so it reads the file as before
(request_disk_map_other.go).
decodeMapped keeps the decode's closure out of unpackReusing: with the
closure there, data escaped to the heap and every row's take() through
it was slower, which made step 2 0.12-0.2s slower than before (found by
profile: unpackReusing.func2 0.28s -> 0.64s over three runs).
Run at this tree, on the owner's real data (sandbox HOME with
.claude/projects and .codex/sessions linked read-only, ~421k rows), warm
runs interleaved with v0.1.1471 (
|