f2eb56c6bbde1300dddc402861b59cd4e45e0215
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
936bdccfab |
gui: the page reads hand memory back only after 30s at rest, past every poll (#2278)
An open Usage or Sessions window polls every 10s and 15s. With a 3s rest, every poll's pages were handed back (ReleaseScratch + FreeOSMemory) and taken back by the next poll: in the CPU profile, 1.88s of 1.95s madvise was runtime.sysUsed re-committing them, and the matcher's scratch was made again on every poll. 30s outlasts both polls, so the pages go back once a window stops polling, not between an open window's polls. Measured on mote (~/r2278 run2278d: 10 endpoints every 5s, gateway feed from 60s, real ~/.codex and ~/.claude copy), 60s CPU profile, 3s vs 30s: GC mark workers 6.92s -> 4.76s madvise 1.81s -> 1.18s avg RSS after 60s 893 -> 925 MiB (+32 MiB while polling) Latency was not comparable (mote load 40-73 during the run). The binary measured was this constant at |
||
|
|
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 |
||
|
|
94a70f1a0d |
gui: what a Sessions or Usage poll threw away goes back once the page rests
An open window's Sessions and Usage polls allocate ~330 MB every 15 s to keep ~105 MB, and Go's scavenger hands the freed pages back only slowly, never while the next collection's goal covers them: between polls the footprint sat at 336-392 MB. The gateway already hands its requests' pages back once it rests (#3472), but the window's reads go through the GUI's handler, not the gateway's, so nothing ever did that for them. held now counts the /api/sessions and /api/usage reads (readingPage), and once none has been in flight for 3 s (a poll's reads come within a second of one another) it calls debug.FreeOSMemory, as the warm-up does after its reads. Measured on a copy of the owner's real history (rss-home, 3581/3582, 8 GUI-like poll cycles 15 s apart, footprint 10 s into each rest), at |