Skip to content

feat(id): stress_mem memory profile — RSS per resident world, compaction spike (#13086) - #13224

Merged
dezren39 merged 3 commits into
mainfrom
lane-rf-13086
Nov 23, 2026
Merged

dezren39 merged 3 commits into
mainfrom
lane-rf-13086

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes #13086 — the memory-profile slice of the #6304 scale & performance stress program (breakdown item 4).

What lands

  • stress_mem profile in pkgs/id/benches/world_bench.rs with two measurements:
    • RSS per resident world at the selected stress tier: the tier's idle worlds (lone Created header each), active worlds, and hot world are restored through the real WorldCore::restore path and held resident; RSS (VmRSS/VmHWM from /proc/self/status) is sampled between phases, so the line reports per-class marginals (idle / active / hot) plus the blended per-world number. A restore failure stops growth and is recorded as the tier's wall, per the design's run protocol.
    • Compaction spike: a journal of 2,000 and of 100,000 entries is bulk-written as a fixture (the generator's own entry construction), then the measured operation runs the stack's real path — recover via FileJournal::open, restore, hold resident, FileJournal::compact to the 64-entry checkpoint set the compaction bench uses. Spike = peak RSS during the operation − RSS just before it.
    • ID_BENCH_STRESS_MEM_PART (all/compact/resident) runs one part per process when attribution matters; tier/seed follow the existing stress_gen knobs.
  • Verbatim refactor: the generator's journal-entry construction moves into stress_world_entries, shared by stress_gen and stress_mem. Verified character-identical to the original inline block (1,224 chars), and stress_gen --quick produces the identical hot state hash (8ef2ffc8a61f687b) before and after.
  • Limits table updated in the id(phase-14): Scale & performance hardening — v1 — first-iteration design #6304 design doc with the three measured rows below.
  • This branch is merged with current main, including id(phase-14): frame cost vs world state size — view fuel and wall time at 10k/100k/1M events #13085's frame_cost profile and fix(id-bench): recover stress_gen after interrupted generation #13181's staging-publish generator change; both profiles coexist (9 registered benchmarks), and all numbers below were re-measured on the merged tree.

Results — reference laptop (Ryzen 7 7840U, 123 GB RAM, NixOS), medians of 5 runs per measurement

Measurement Result
Resident RSS, 1x (1,101 worlds) 21,834 B/world blended; 28.56 MiB total; idle 11,350 B/world; active (100 events) 93,593 B/world; hot (10k events, 32 members) +3,280,896 B; peak 34.49 MiB
Resident RSS, 10x (11,001 worlds) 18,320 B/world blended; 197.90 MiB total; idle 9,334 B/world; active 87,945 B/world; hot (100k events, 256 members at the codified cap) +20,250,624 B; peak 258.76 MiB
Compaction peak memory, 2,000 entries 5.59 MiB over pre-op RSS (5,861,376 B)
Compaction peak memory, 100,000 entries 89.34 MiB over pre-op RSS (93,679,616 B)

Both tiers' resident sets are fully held — no wall at 1x or 10x on the reference laptop, and no eviction engages on the restore path (eviction lives in the hub/actor layer, not in WorldCore::restore); resident-set growth is the phase progression above. Per-tier spread across the 5 reps was <1% on every headline number except the small 2,000-entry compaction spike (~±3%).

Verification

  • cargo build --release --bench world_bench clean on the merged tree (only pre-existing warnings; none in the new code); cargo fmt --check clean for the bench file.
  • --quick smokes on the merged binary: stress_gen (identical hot hash), stress_mem, and frame_cost (view fuel 958,616, matching id(phase-14): frame cost vs world state size — view fuel and wall time at 10k/100k/1M events #13085's recorded values) all pass.
  • The recorded runs are the full-size 1x/10x/compact runs from the merged binary.
  • Remote dispatch was not used: this measurement is only meaningful on the reference laptop itself (RSS of the measuring process), so the laptop run is the verifying route by construction.

…ion spike (#13086)

New world_bench profile measuring the #6304 scale program's memory
axis: RSS per resident world at the selected stress tier (the tier's
idle, active, and hot worlds restored through WorldCore::restore
and held, RSS sampled between phases), and the peak additional RSS
while compacting journals of 2,000 and 100,000 entries (recover via
FileJournal::open, restore, hold resident, compact to the
checkpoint-sized set). The generator's journal-entry construction
is extracted verbatim into stress_world_entries so the profile
restores exactly the worlds the generator materializes.

Reference-laptop results (medians of 5 runs each) are recorded in
the #6304 design's limits table: 21,011 B per resident world
blended at 1x and 18,223 B at 10x, both tier resident sets fully
held (no wall), and a compaction peak of 4.88 MiB over pre-op RSS
at 2,000 entries and 89.41 MiB at 100,000 entries.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0b48dafa-e512-4f6e-af59-86e4f87861c2
Commits

Reviewing files that changed from the base of the PR and between 016e55c and 5c2839e.

Files selected for processing: 2

  • doc/2026-11-23T07-53-00Z_design_scale_perf_stress_v1/2026-11-23T07-53-00Z_design_scale_perf_stress_v1.md
  • pkgs/id/benches/world_bench.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T11:48:54.227448Z 5c2839e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1d58bb2b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2389 to +2390
let (_, peak) = rss_bytes()?;
let spike = peak.saturating_sub(rss_before);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope peak RSS accounting to the measured operation

rss_bytes() returns the process-lifetime VmHWM, not the peak since rss_before. Whenever fixture construction or an earlier benchmark reaches a higher RSS than the measured operation, this subtraction reports that earlier peak as the compaction spike. This can happen even with ID_BENCH_STRESS_MEM_PART=compact: fixture setup allocates both the full entry vector and serialized journal before the baseline, and both compaction sizes run in the same process. Reset peak accounting after fixture setup for each measurement, or sample RSS only within the measured interval, so the reported spike actually belongs to recovery/restore/compaction.

Useful? React with 👍 / 👎.

# Conflicts:
#	doc/2026-11-23T07-53-00Z_design_scale_perf_stress_v1/2026-11-23T07-53-00Z_design_scale_perf_stress_v1.md
#	pkgs/id/benches/world_bench.rs
@dezren39
dezren39 merged commit 36b25a0 into main Nov 23, 2026
1 check passed
@dezren39
dezren39 deleted the lane-rf-13086 branch November 23, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id(phase-14): memory profile at scale — RSS per resident world and compaction spike

1 participant