Skip to content

perf(gateway): read Character state through maintained indexes - #712

Merged
Mathih13 merged 2 commits into
mainfrom
perf/gateway-read-indexes
Oct 16, 2026
Merged

Mathih13 merged 2 commits into
mainfrom
perf/gateway-read-indexes

Conversation

@Mathih13

@Mathih13 Mathih13 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Inventory, skill, quest and armor reads copy whole SDK tables before selecting one Character's rows. Loot projections repeat membership scans for each viewer.

Maintain connection-owned indexes for inventory, skills, quest state, loot entitlement, target auras and enchantments. Materialize matching rows through primary keys. Protect cache publication and index callbacks with one snapshot lock, and rebuild indexes on reconnect. SDK callbacks queue the guarded projections so they do not acquire the read lock on the pump thread.

Part 3 of 6. Follows #711. Merged in stack order. Next: #713.

Verification

CI now tests real SDK subscriptions, owner changes, duplicate-row deletion, a Store read paused across SDK callbacks, and fresh indexes after reconnect.

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 4149e715: 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

The snapshot lock keeps index selection and keyed materialization consistent; it does not make an entire multi-read projection atomic. No memory or capacity measurements were run. No capacity gain is claimed.

Risk

The indexes must match the SDK cache generation. The publication lock must remain outside synchronous SDK callbacks. The tests cover ownership changes, deletion, duplicate membership rows and fresh index generations.

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

@Mathih13
Mathih13 force-pushed the perf/simulation-candidates branch from 64abed4 to 9d24f1c Compare October 16, 2026 06:21
@Mathih13
Mathih13 force-pushed the perf/gateway-read-indexes branch from 4b93fe1 to 4149e71 Compare October 16, 2026 06:21
@Mathih13
Mathih13 changed the base branch from perf/simulation-candidates to main October 16, 2026 06:48
@Mathih13
Mathih13 merged commit 7359dda into main Oct 16, 2026
9 of 18 checks passed
@Mathih13

Copy link
Copy Markdown
Contributor Author

Merged after adversarial review and repairs. Added real Coordinator tests for subscription population, owner changes, deletion, duplicate membership rows, Store reads during SDK callbacks, and fresh indexes after reconnect.

All nine checks passed at 4149e715: 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