feat(server): commit cellular batches on a background thread
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m28s
Foundation / postgres-tools (push) Successful in 23s
Foundation / server-image (push) Successful in 4m27s
Foundation / image (push) Successful in 4m31s

The rules-12 loop blocked for ~411 ms per 20-tick commit, so players saw
one-second bursts. The host now commits a batch on a worker thread with
its own connection (begin_publish / poll_publish), using the builder's
already-simulated candidate. The next batch builds on that candidate
under a provisional head and is rebased when the commit lands. One commit
is in flight at a time; births and mutation choices wait for a batch that
starts on the durable head, and host reconciliation pauses meanwhile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-22 08:41:56 -04:00
co-authored by Claude Opus 5.5
parent 4112bef52c
commit ff333d97c2
6 changed files with 403 additions and 37 deletions
@@ -82,6 +82,19 @@ class CellularSessionBatchBuilder {
[[nodiscard]] const CellularLives& candidate() const noexcept {
return *working_;
}
// Hands the working state to a commit; the builder is spent afterwards.
[[nodiscard]] std::unique_ptr<CellularLives> take_candidate() noexcept {
return std::move(working_);
}
// A batch started on an uncommitted predecessor (a commit still in flight) takes that
// predecessor's real head once it is known. The head must end where this batch begins.
[[nodiscard]] bool rebase(const persistence::RegionHead& head) noexcept {
if (head.frame != batch_.header.frame || head.end_tick != batch_.header.begin_tick)
return false;
batch_.header.predecessor = head.commit;
batch_.header.predecessor_digest = head.digest;
return true;
}
// The owner's own refusal behind the last `biology` error, for operator logs.
[[nodiscard]] std::optional<CellularLivesError> last_lives_error() const noexcept {
return last_lives_error_;