Skip to content

perf(gateway): release idle World Sessions from blocking workers - #713

Merged
Mathih13 merged 2 commits into
mainfrom
perf/async-world-sessions
Oct 16, 2026
Merged

Mathih13 merged 2 commits into
mainfrom
perf/async-world-sessions

Conversation

@Mathih13

@Mathih13 Mathih13 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Each World Session keeps reader and writer threads while idle. Connection count therefore consumes blocking workers, and queued outbound jobs have no fixed limit.

Use asynchronous World socket I/O and login-queue waits. Run synchronous Store calls and Relay encoding through bounded worker pools. Add a separate accepted-connection limit, outbound count and byte reservations, queue-age limits, and batched writes. A supervisor owns cleanup until accepted game work completes. One writer owns the header cipher and preserves packet order.

Part 4 of 6. Follows #712. Merged in stack order. Next: #714.

Verification

World Session and wire tests now use the production async transport. They caught truncated-body handling, entry packets lost before a later Relay closed the socket, and delayed socket closure during accepted work. The repairs preserve FIFO writes and retain admission seats and connection permits through cleanup. The cancellation regressions failed before the repair and passed after it.

Two independent adversarial review rounds are complete. No actionable finding remains. The reviewed stack passed offline binding generation, formatting, workspace Clippy with all targets and features, and the Gateway unit and integration test targets. The Gateway binary passed 2,148 tests. Local builds used one job; no local SpacetimeDB instance or load test ran.

All nine checks passed at 76dd8df3: Module durable tests and Gateway bindings, Runtime Scripts, Rust.

Comment review passed for the final changed source, tests, scripts and configuration. Retained protocol and ordering contracts match the code.

Verification limits

No real build-5875 client, capacity run, or slow-client load test was run. Store calls remain synchronous behind bounded workers. No capacity gain is claimed.

Risk

This replaces the production World transport. Queue overflow or an expired outbound entry closes the World Session. Typed messages and deferred jobs use byte reservations, which are not an exact heap bound on captured Rust objects. LYRACORE_MAX_WORLD_CONNECTIONS defaults to 16,384 accepted sockets; this is a limit, not a measured capacity.

Models: GPT-6 Astra. Harness: Codex in T3 Code.

@Mathih13
Mathih13 force-pushed the perf/gateway-read-indexes branch from 4b93fe1 to 4149e71 Compare October 16, 2026 06:21
@Mathih13
Mathih13 force-pushed the perf/async-world-sessions branch from 5a006cc to 76dd8df Compare October 16, 2026 06:21
@Mathih13
Mathih13 changed the base branch from perf/gateway-read-indexes to main October 16, 2026 06:51
@Mathih13
Mathih13 merged commit d1ea630 into main Oct 16, 2026
9 of 18 checks passed
@Mathih13

Copy link
Copy Markdown
Contributor Author

Merged after adversarial review and repairs. World Session tests now exercise the production async transport. The repairs keep earlier packets ahead of later Relay jobs, close sockets during accepted work, and retain admission seats and connection permits until cleanup finishes. The new cancellation regressions failed before the repair and passed after it. Review repairs.

All nine checks passed at 76dd8df3: Module durable tests and Gateway bindings, Runtime Scripts, Rust.

Comment review passed. No real-client or capacity measurement is claimed.

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.

1 participant