ac4af582301a4e8a29245dbba767eba31334ddf9
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
64aaf421ac |
usage: a packed row holds its time as unix ns and a zone, its tokens in 32 bits (#2278)
A packedRow was 184 bytes; it is 152 now. Its time.Time (24 bytes) is
kept as unix nanoseconds and the *time.Location it was in, read back
with Time(); its six token counts are int32s, not int64s. No call
reads or writes 2^31 tokens; one past it is kept as the most an int32
holds (tokensOf), not wrapped. The archive's encoding is varints and
is unchanged.
Run (mote, through mote-run): go build, go vet, GOOS=linux and
GOOS=windows go vet ./internal/usage, go test ./internal/usage
./internal/usageapi: ok. TestRowTokensAndZoneKept (new) packs a row in
a +05:30 zone at 123ns with 3e9 and -3e9 tokens, and checks time,
zone and the saturated counts after a pack/unpack round trip.
Broken by hand: tokensOf as a plain int32(n) makes it red ("read back
Input -1294967296 ... want 2147483647").
Real history copy on mote (cold start, magpie-ext = v0.1.2296 change):
cold peak this 346/342/354 MB (avg 347) before 373/349/359 (avg 360)
warm peak this 273/262 MB before 297/276
heatmap, overview 0/7/30, stats 0/30 and the request page JSON are
byte-identical to before.
|
||
|
|
a6e7d40421 |
usage: the heatmap pairs its year through All's pairing, not a third time (#2278)
A cold start paired the whole history three times in turn: the page of All, Codex's effort through All's memo, and the heatmap's 53 weeks on their own. The year covers the same chunks as All for most histories, and its pairing was the last and highest of the footprint's peaks (fp 503 -> 565 -> 574 -> 582 -> 592 MB as each pairing ran, e18 on the real history). heatSplit's cold path now pairs through pairEvery: All's window and All's memo (cache.pairs), visited from the heatmap's since on. Whichever of the page of All, the effort and the heatmap comes first pairs every row; the others take the memo. A call is paired to its session row as the whole history pairs it, so a call early in the year can match a session row from before it, as the page of All already counts it. Only the heatmap's recent days are paired again for it. On a cold start this alone moved no peak (597/619/595/611 MB against e18's 592-628): every build missed the memo, for the reasons the next commit fixes. With it, the effort, the page of All and the heatmap take one pairing. TestHeatmapPairsAsAllDoes counts the pairings with the page first and with the heatmap first; both orders are red on the old code. Run at this head, rebased on |
||
|
|
f8088cb2d1 |
usage: a page whose settled days are kept leaves the gateway's older blocks unpriced (#2278)
Every query of All priced and unpacked every gateway block of the history
before it looked at what it needed. With the page's cells, the heatmap's
days and Codex's effort kept from earlier days (page-v1, heat-v1,
effort-v1), a cache hit reads only the last days' rows. Pricing the rest
was still 53 MB of the 219 MB heap at 18s on the real history
(blockPricer.priceBlock: 38 MB of pooled rows, 14 MB of unpacking).
readRequestBlocks now leaves a packed, named block whose newest call is
before settledBefore(now) (the splits' edge) as a stub: its serial, count
and latest time, the raw block and the pricer. priceStubs prices stubs in
place, and every pairing calls it first (pairRowsIn, pairRowsMemo,
heatBefore). So a miss, a page of older rows, or a period the splits don't
cover prices them as before. rowsIn counts a stub by its raw block.
heatSettledKey names a gateway block by its raw rows, which requestState's
meta prices, so a priced block and a stub get one key. That changes the
keys once; this binary's own keys already change.
Run at
|
||
|
|
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 ( |
||
|
|
0dc4cec85d |
usage: a row's Codex thread is kept as a 4-byte place, not a string (#2278)
Every row of a chunk had a 16-byte string header for its Codex
thread. A day's rows are a few hundred threads, one after another. At
the scale of #2278 (34k session files, 1M Codex rows), these headers
were the largest single holder in the heap, 24.5 MB of 184 MB live.
codexActors now keeps a []uint32 into the chunk's thread names. The
row before's thread is checked first, then the names. A clone shares
the names clipped, so adding a name to one never writes into the
other. The disk format is unchanged: each row's thread is still
written as a string.
Measured on mote, at 7e58591dc's parent with this change. The history
is synthetic: 25,000 Codex rollouts and 9,000 Claude Code sessions, 40
turns each (13 GB), plus a 115 MB usage.jsonl of 240k gateway calls on
the newest 3,000 of each. Cold `magpie web --no-open` in a sandbox
HOME, with `magpie heap` taken at 130 s:
- main: live heap 195.2 MB (both runs), physical footprint peak 389 to
417 MB.
- this change: live heap 175.6 MB, physical footprint peak 366 MB.
The reporter's 0.1.1318 peaked at 2.85 GB RSS on such a history.
Run at the pushed head (rebased onto
|
||
|
|
4982ded8a6 |
usage: a turned page reuses the last pairing while its chunks are the same
A Requests page paired every Codex session file's calls with the
gateway's again on each query: clone, fold forks, match response ids.
That unpacked every session chunk three times and was about half of a
warm page (#3493). pairRowsMemo names the chunks of a pairing by their
serials (the probe chunk, which has none, by its rows' log offsets and
times) and keeps what the pairing found: the rows left out (skip,
matched), the actors it changed and each chunk's compactions. The next
query over the same chunks and window applies that to fresh clones
instead of pairing again. A changed file gets a new serial, a new
window or period misses, and adopt drops the memos with the parts.
Run at
|