Title: id(world): many_worlds p99 is blocking fdatasync on Tokio workers, capped at ~1.5k commits/s (not algorithmic) · Issue #5502 · developing-today/code · GitHub
Open Graph Title: id(world): many_worlds p99 is blocking fdatasync on Tokio workers, capped at ~1.5k commits/s (not algorithmic) · Issue #5502 · developing-today/code
X Title: id(world): many_worlds p99 is blocking fdatasync on Tokio workers, capped at ~1.5k commits/s (not algorithmic) · Issue #5502 · developing-today/code
Description: What The F11.8 `many_worlds` reference measurement (`benches/BASELINES.md`, #557) misses its p99 target: 5,650.8 ms vs 50 ms, with completed throughput 1,523.1/s against 2,000/s scheduled. The cause is not an algorithmic O(n) problem in ...
Open Graph Description: What The F11.8 `many_worlds` reference measurement (`benches/BASELINES.md`, #557) misses its p99 target: 5,650.8 ms vs 50 ms, with completed throughput 1,523.1/s against 2,000/s scheduled. The caus...
X Description: What The F11.8 `many_worlds` reference measurement (`benches/BASELINES.md`, #557) misses its p99 target: 5,650.8 ms vs 50 ms, with completed throughput 1,523.1/s against 2,000/s scheduled. The caus...
Opengraph URL: https://github.com/developing-today/code/issues/5502
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(world): many_worlds p99 is blocking fdatasync on Tokio workers, capped at ~1.5k commits/s (not algorithmic)","articleBody":"## What\n\nThe F11.8 \\`many_worlds\\` reference measurement (\\`benches/BASELINES.md\\`, #557) misses its p99 target: 5,650.8 ms vs 50 ms, with completed throughput 1,523.1/s against 2,000/s scheduled. The cause is **not** an algorithmic O(n) problem in the journal. Each durable commit runs a synchronous \\`fdatasync\\` on a Tokio worker thread, so concurrent commits are capped at the worker count and the rest queue.\n\n## Evidence\n\n**Per-append path** (no O(journal) work — checked):\n\n- \\`src/world/actor.rs:444-469\\` — \\`WorldActor::persist\\` is synchronous and calls \\`journal.append\\` inline from the actor task.\n- \\`src/world_store.rs:184-204\\` — \\`FileJournal::append\\`: one \\`write_all\\`, then \\`self.file.sync_data()\\` at **:202**. No directory fsync, no re-read, no re-encode of the journal.\n- Per input: 1 fsync, 1 write, 3 full JSON encodes (\\`actor.rs:482-485\\` for replication, \\`core.rs:29-31\\` / \\`:1983-1985\\` for admin-history sizing, plus the journal line), and ~4 event clones (\\`actor.rs:1370\\`, \\`core.rs:1964,1968\\`).\n\n**Concurrency cap** (\\`benches/world_bench.rs:704-708\\`): the runtime is \\`new_multi_thread().worker_threads(available_parallelism())\\` = 16 on the reference laptop. The bench drives 100 active worlds at 20 commits/s = **2,000 fsyncs/s**. Each fsync blocks one worker, so at most 16 are ever in flight.\n\n**Micro-benchmark** (same filesystem, 64-byte appends to 100 files, \\`fdatasync\\` timed):\n\n| concurrency | fsync/s | p50 |\n|---|---|---|\n| 1 thread | 168 | 5.5 ms |\n| 16 | 1,190–1,456 | — |\n| 32 | 2,083 | — |\n| 64 | 2,648 | — |\n\nThe bench's 1,523 completed/s sits at the 16-way ceiling. Backlog ≈ (2000−1523)/1523 ≈ 3 s, which matches the p99.\n\n**Secondary (smaller, same area):**\n\n- \\`src/world/core.rs:503-506\\` — open re-serializes every journal entry with \\`serde_json::to_vec\\` just to charge the memory budget, on the async worker.\n- \\`src/world_store.rs:416-421\\` — \\`WorldCore::restore_with_runtime\\` runs on the runtime worker in \\`open_world\\`, while \\`FileJournal::open\\` is offloaded.\n- \\`src/world_hub.rs:601-622\\` — eviction shuts victims down before the requested world opens (\\`:539-541\\`), serialising leases behind the victim's in-flight command.\n\n## Proposed fix (ranked)\n\n1. **Take the fsync off the runtime worker.** Give \\`FileJournal\\` a dedicated writer thread (request channel → write + \\`fdatasync\\` → reply) so \\`WorldJournal::append\\` keeps its contract and ordering. Do not use \\`block_in_place\\`: \\`FileJournal\\` is also called from \\`spawn_blocking\\` during open. Estimated 40–50 lines. Expected to lift the cap from ~1.5k to ~2.5k fsyncs/s.\n2. **Group commit.** One flusher writes all pending per-world appends and issues one \\`syncfs(2)\\` per batch. This is the only design that reliably sustains 2,000 durable events/s under 50 ms p99 on this device. Risky (per-world error attribution, compaction ordering, replication snapshots), so it deserves its own design doc per \\`pkgs/id/AGENTS.md\\`.\n3. Move \\`restore_with_runtime\\` into the existing \\`spawn_blocking\\` in \\`open_world\\` and drop the redundant encode/clones listed above.\n\n## Acceptance\n\n- \\`cargo bench --bench world_bench\\` on the reference machine: \\`many_worlds\\` p99 \u003c 50 ms, or a recorded result with the target still missed and a reason.\n- \\`journal_append_fsync\\` baseline unchanged (5.18 ms/append) or explained.\n- Checkpoint/eviction/reopen assertions in \\`many_worlds\\` still pass.\n\nRelated: #557 (the target this measurement belongs to). Found while profiling for PR #5500 (Bolt, #5489); not addressed there.","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-04T14:27:17Z","url":"https://github.com/developing-today/code/issues/5502"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eabe360c-b05d-1768-9ced-7a616ff0b2ba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0A6:829B4:1FED77:2C27D1:6B06F91B |
| html-safe-nonce | fb5e17164c52f84d27209cf3283b64d583e0b4e043c0d52f015c7e3e1419d51e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEE2OjgyOUI0OjFGRUQ3NzoyQzI3RDE6NkIwNkY5MUIiLCJ2aXNpdG9yX2lkIjoiMTk1NDYxNDkzNTAyODE2ODk4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ac70bd8f8d9a902223f384f40146ec6e4b3c5d7f9dabede93a2bc5f7b54afe8f |
| hovercard-subject-tag | issue:6204724962 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/5502/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a2971530a1319ba7c2d94500d2cb2de8a4ef4233dc176a3ab1c5b31a6ddb13c0/developing-today/code/issues/5502 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a2971530a1319ba7c2d94500d2cb2de8a4ef4233dc176a3ab1c5b31a6ddb13c0/developing-today/code/issues/5502 |
| og:image:alt | What The F11.8 `many_worlds` reference measurement (`benches/BASELINES.md`, #557) misses its p99 target: 5,650.8 ms vs 50 ms, with completed throughput 1,523.1/s against 2,000/s scheduled. The caus... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 518c89df9981b23ef4bf1cf9e25792a20e5884aa6a2efccd817801f8bae3dd64 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3e66657d0989666cd38e3fb0fbd4e0c116e481e6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width