Avoid duplicate peer snapshot size serialization
HOLD: Investigating the measured CPU increase with a paired base/head run on one worker before landing.
Peer snapshot eviction and replacement serialized each removed record twice. They now compute its serialized size once. Size calculation uses a counting writer instead of allocating a Vec. Coverage, ordering, eviction and disk limits remain unchanged; retained and queued limits remain 16 MiB of serialized bytes, not heap.
Leo's words (2026-10-28): "And especially, like, say, you know, how much RAM, how many CPU cores are we taking with all these things? Are there ways to make things more efficient? Like these are all things that are under our umbrella that we need to do, and we need to do really, really fucking well."
Validation:
- Base allocation regression RED: 40786236156, job
d46e3ecfbf1345138c2bd2716972483e:record_bytes allocated 1 times, expected zero. Identical new tests copied onto base. - Head compilation, 43 store tests and six daemon measurement cases GREEN: 40786203182, job
5ed2e5b51b934e8fac4b69a2aea81246. - The broader disk/read/store test selection, including the head allocation regression, is dispatched in 40787019455.
- Independent Codex gpt-6-astra high/fast SHIP at
1d96c98741acb321fbb4617654ac8b1b66776891.
Performance
Base 1f0f687b2f32a9f506e19e7f683e8362fd3da6b2; fix 1d96c98741acb321fbb4617654ac8b1b66776891. Identical hermetic daemon_memory::peer_snapshot_cache_saturation_cost_with_object_heavy_payloads on 16-vCPU Linux: ten fixed remote sessions × 400 nested-object records, two attach/read passes, plus N retained idle or closed local sessions. Measurements count the receiving daemon alone. All six cases verify actual cached records and last sequence.
| metric | before | after | delta | harness or run link |
|---|---|---|---|---|
| idle, N=0: RSS KiB | 781368 | 841464 | 60096 (7.7%) | base / head |
| idle, N=0: peak RSS KiB | 795208 | 841464 | 46256 (5.8%) | base / head |
| idle, N=0: CPU ms | 9400 | 15570 | 6170 (65.6%) | base / head |
| idle, N=288: RSS KiB | 858716 | 920804 | 62088 (7.2%) | base / head |
| idle, N=288: peak RSS KiB | 873572 | 920804 | 47232 (5.4%) | base / head |
| idle, N=288: CPU ms | 8790 | 14070 | 5280 (60.1%) | base / head |
| idle, N=1000: RSS KiB | 996204 | 1053980 | 57776 (5.8%) | base / head |
| idle, N=1000: peak RSS KiB | 1014208 | 1053980 | 39772 (3.9%) | base / head |
| idle, N=1000: CPU ms | 9120 | 14920 | 5800 (63.6%) | base / head |
| closed, N=0: RSS KiB | 909660 | 811176 | -98484 (-10.8%) | base / head |
| closed, N=0: peak RSS KiB | 929124 | 811176 | -117948 (-12.7%) | base / head |
| closed, N=0: CPU ms | 9290 | 13510 | 4220 (45.4%) | base / head |
| closed, N=288: RSS KiB | 842616 | 1043932 | 201316 (23.9%) | base / head |
| closed, N=288: peak RSS KiB | 853664 | 1043932 | 190268 (22.3%) | base / head |
| closed, N=288: CPU ms | 9780 | 15280 | 5500 (56.2%) | base / head |
| closed, N=1000: RSS KiB | 1166752 | 1191988 | 25236 (2.2%) | base / head |
| closed, N=1000: peak RSS KiB | 1179692 | 1191988 | 12296 (1.0%) | base / head |
| closed, N=1000: CPU ms | 8810 | 13850 | 5040 (57.2%) | base / head |
These first measurements do not establish an overall performance improvement: CPU rises and RSS varies. A paired same-worker run 40787169549 is checking that signal. The allocation test proves removal of the temporary serialization buffer, but object-heavy JSON still amplifies substantially in heap. No new heap limit is asserted from a serialized-byte budget. No timers added; both fixture daemons are reaped.
Duplicate searches found no matching sizing fix. pr-overlap was attempted but its request form was rejected by the broker.
Agent session: agent session