Repository navigation
Sonny: the sky, its replay and the lookout stay light at 10,000 agents - #655
Merged
Merged
Conversation
Measured first at 1,000 and 10,000 agents, then changed only what the numbers named: - A replay's tape keeps each event as its text, with when it was written and whether it made an agent beside it, rather than parsed: 95,000 events took 178 MB, now 22 MB. - The sky works out an agent's model name once, when its model changes, and only on `m` colours by it; it picks the stars it has room for rather than sorting every agent. A 10,000-agent frame: 5.5 ms p50, 9.0 ms p95 before; 2.3 ms and 2.6 ms after. - The busiest agent's window keeps a count for each agent as notes come and go, and each note names its agent by a place: 1.2 million notes in a ten-minute window took 86 MB and 16 ms to weigh each second, now 31 MB and 0.2 ms. - The lookout works out what each subscriber watches from one index of who made whom, rather than every bot listed for each subscriber and each generation; and lets go of the start's listing once it is in `records`. 10,000 bots, 100 leads: start CPU 1.9 s to 0.8 s, seated 1.1 s to 0.5 s. Harnesses: sky::scale::fleet_profile, haiku::scale (ignored tests), bench/lookout_scale.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGG6mPjP8vkAvVqVgk
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
lydakis
pushed a commit
that referenced
this pull request
Nov 2, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGFQFsMWT3ryazYxU9H
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One data-oriented pass over Sonny's in-memory structures at fleet scale. I measured first at 1,000 and 10,000 agents and changed only what the numbers pointed at. No daemon change, no protocol or schema change, and nothing visible changes, so there's no FEATURES.md row.
What changed, and why
Replay.tape)serde_json::Value. Each object is a BTreeMap node, so a slim event cost about 1.9 KB.Taped).written_ms, and whether the event made an agent, sit beside the text soseekandplayed_tocan read them without parsing. An event is parsed when it plays.card)hues()ranmodels::namedfor every agent on every frame, even withmoff.shown()sorted every agent to pick the toproom.Agent::set_model). Model colours are computed only onm.select_nth_unstable_byreplaces the full sort; the order is total, so the stars chosen are the same.haiku::Title)String, andcrownrebuilt a count map over the whole window every second.u32place for its agent, and places are reused once their count is zero.crowngoes through the agents, not the notes. Same rules and tie-breaks.grow/roots)others,theirs,globbed, and thensyncover every name.Madeis an index of who made whom (by maker, plus the leads listed), kept as bots are created and deleted. Lineages are walked through it.globbedis computed only when a subscription has--botglobs, andsyncchecks only the names that could be watched.watch()kept the wholebotslisting alive for the life of the connection, next to its copy inrecords.drop(bots)after its last use.At 1,000 agents nothing got worse. Lookout start: 0.04 s → 0.05 s CPU (noise), 27 MB both. The sky frame is 1.1 → 0.8 ms.
What I kept and left alone
heldpagination, and the status projection (Capacity: sky replay's start reads all retained history #598 item 3, which needs a daemon change). I checked with that thread before starting; it reported no overlap.hearing). During a first start's full replay that costs about 25% of start CPU, but in steady state it is O(subscribers) per event. The lookout'srecordsmap holds full listing values, about 30 MB at 10k. Making it compact would mean changing every place that reads it, so I've left it as a follow-up if it ever matters.How it was measured
sky::scale::fleet_profile(ignored test, new):SKY_AGENTS=10000 cargo test -p sonny --release fleet_profile -- --ignored --nocapture. It seats the agents and a past, drains 200k live events in batches, runs 200 frames with count/20 events per frame, and fills a replay tape. RSS is read aftermalloc_trimon Linux.haiku::scale::the_window_at_fleet_scale(ignored test, new). It uses only the public API, so I ran the same test against base cefecb8.bench/lookout_scale.py --projects 100 --tasks 100 --phases idle,restart(and 10×100 for 1k), with the agent binary fixed at base, swapping onlysonny. Base was run 2×, new 4×. massif and callgrind were run on the lookout at 10k.Checks
cargo fmt --all --check,cargo clippy --locked -p sonny --all-targets -- -D warnings: clean.cargo test --release --locked -p sonny: 996 passed, plus the integration tests.