ac4af582301a4e8a29245dbba767eba31334ddf9
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5bb252c8f3 |
usage: a poll's small pairing lets a whole history's scratch go (#2278)
The matcher, the response picks and visibleLocal's set of ids seen are kept for the next pairing, and each pairing that puts one back holds it scratchLinger more. A poll's pairing of its last few days put back the scratch the cold start's pairing of the whole history made, sized for every call, so ~140 MB of maps and slabs stayed while the window polled: the heap profiles at 44, 50, 56, 62 and 68 s were alike to the MB, all of it under codexEffortOfIndex, with no pairing of the history running. Each scratch now records the rows of the largest call it served, and a call over a quarter of that or less (and over 4096 rows' floor) makes its own; the large one goes with the collection. A call alike in size takes what is kept, as before, so the polls while an agent works still reuse it. holdBigBuild counts its rows through the same rowsOfAll. Run on mote at this head (parent |
||
|
|
70d9996c57 |
usage: a pass's decode buffer is kept past a collection, not grown again after every GC (#2278)
chunkRows decoded each chunk into a rowBuffer from a sync.Pool. A poll
while an agent works collects several times a second, and each
collection emptied the pool, so the next pass grew a buffer to the
largest session chunk again. In 90 s of polls on the 65 GB bench HOME,
unpackReusing allocated 779 MB (486 MB flat), 553 MB of it under
matchedBlocks.
The buffers are now kept as the matcher's scratch is: up to four in
keptRows (atomic pointers), taken by chunkRows.of and put back by
release, and let go with the scratch, on ReleaseScratch or scratchLinger
after the last pass.
Run on mote at this tree, rebased on origin/main:
- go test -count=1 ./internal/usage/ ./internal/usageapi/: ok, at ae906d4df on
|
||
|
|
fddd7ff08f |
usage: pairing keeps its rows as bits and its groups by sums, and lets its pairs go (#2278)
A cold start pairs the whole history, and pairing held its row sets as map[rowRef]bool, ~40 bytes a row, several sets of most rows at once. They are now refSet: a bitset a chunk, a bit a row. matchScratch's groupOf was keyed by the whole matchKey (a session string and its tokens); it is keyed by a 128-bit maphash sum of them now, and the sessions map is filled when a group is made. pairedRows' pairs and compactions maps were filled and never read; they are gone. Measured on mote, a copy of the real full history (52G Codex, 13G Claude), GODEBUG=gctrace=1, 120s of /api polls, 3 rounds each, alternating, v0.1.2143 ( |
||
|
|
99c2567cfa |
usage: the matcher's scratch goes 30s after the last pairing used it (#2278)
With nothing new to pair, every poll of the window is answered from the pairings kept (pairMemo) and pairs nothing, so the scratch of one pairing of the whole history (keptMatch's groupOf/calls/ends/byID maps, keptPicks' picks and slab) sat unused while the window polled, until pageRest's ReleaseScratch 30s after polling stopped. On the real 65 GB history (52 GB Codex, 13 GB Claude) that was ~120 MB of the ~270 MB live heap over 60s of polls. Now each release of either scratch (re)arms one timer, and scratchLinger (30s) after the last pairing put it back both are let go. While an agent works, every poll pairs again inside 30s and finds it kept, as before. Run at this head (origin/main |
||
|
|
49d4d0f7ab |
usage: the request matcher keeps its maps for the next call, and gives them back once the window rests (#2278)
Every poll while an agent works matches a year's history again: matchedBlocks and codexChunkResponsePairs grew their maps (byID, reserved, used, groupOf, picks, picked, ...) and slices from nothing on each call. They were ~3.0 GB of the ~40 GB a poll-heavy 80 s allocated on the real-history harness (d1951 heap diff, 120 s to 200 s). A sync.Pool was tried first and kept nothing in real use: under tightenGC a poll collects 4-5 times a second (1029 GCs in 230 s), each collection empties the pool, and the matcher's flat allocation went only from 2241 to 1840 MB. So one scratch of each is kept in an atomic.Pointer, emptied after a call (clear() keeps the maps' buckets, and drops every chunk the call saw), and let go by usage.ReleaseScratch, which releaseIfPagesRest calls before FreeOSMemory: once the window's reads have rested 3 s, what the matching kept goes back with the rest. A call that finds the scratch taken makes its own, sized as before. matchedBlocks' result map is now made once the id matches are known, not grown from the response pairs alone. Measured on mote (Apple M5 Pro), at |