Skip to content

perf(runtime): commit accepted mutations outside the speculative-state lock - #61

Closed
kyscott18 wants to merge 1 commit into
mainfrom
perf/pipelined-persist
Closed

kyscott18 wants to merge 1 commit into
mainfrom
perf/pipelined-persist

Conversation

@kyscott18

@kyscott18 kyscott18 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Accepted mutations committed to Postgres while holding the speculative-state lock, so submit, watch, and the next batch waited on the commit. Batches and force-included mutations now commit after the lock is released.

  • Commits stay ordered. Each commit waits for the previous one (a chained deferred, set under the lock). Restart resumes after the highest committed execution index, so a later commit must not land before an earlier one.
  • Callers still get a response only after their batch commits.
  • A batch enters acceptedBatchesQueue when it executes, so simulate always sees the newest journals. submit waits for the commits it covers after simulating, outside the lock, and before it broadcasts. Nothing settles onchain before it is committed.
  • A failed commit stops the program, which fails waiting callers with TypewriterStoppedError.

This lowers latency for work that contends on the lock. It does not raise throughput: the batch loop still runs execute → commit serially.

Test plan

  • bun run typecheck, bun run test (packages/typewriter), biome check
  • Simulation seeds 0x2, 0x3, 0x4 pass

🤖 Generated with Claude Code

…e lock

Batches and force-included mutations committed to Postgres while holding
the speculative-state lock, so submit, watch, and the next batch waited on
the commit. Both now commit after the lock is released.

Commits still run one at a time in execution order: each waits for the
previous one. Restart resumes after the highest committed execution
index, so a later commit must not land before an earlier one.

A batch enters the submit queue when it executes, so simulate always sees
the newest journals. Submit waits for the commits it covers after
simulating, outside the lock, and before it broadcasts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@monad-developers monad-developers deleted a comment from greptile-apps Bot Oct 26, 2026
@kyscott18 kyscott18 changed the title perf(runtime): commit accepted batches while the next batch executes perf(runtime): commit accepted mutations outside the speculative-state lock Oct 26, 2026
@kyscott18
kyscott18 force-pushed the perf/pipelined-persist branch from aca1f79 to bbec4cb Compare October 26, 2026 19:48
@kyscott18

Copy link
Copy Markdown
Collaborator Author

Superseded: the persist-fiber work is moving to a new branch off main.

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