Skip to content

Reduce checkpoint reactor stream fanout#1687

Open
juliusmarminge wants to merge 1 commit intot3code/performance-regression-testsfrom
t3code/perf-checkpoint-reactor-fanout
Open

Reduce checkpoint reactor stream fanout#1687
juliusmarminge wants to merge 1 commit intot3code/performance-regression-testsfrom
t3code/perf-checkpoint-reactor-fanout

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 2, 2026

Summary

  • stop the checkpoint reactor from enqueuing every thread.message-sent event when the pre-turn baseline is already available from thread.turn-start-requested
  • keep the server perf harness on the baseline branch and isolate this change as the first stacked optimization
  • record the first before/after measurements in performance.md

Perf impact

  • create-turn-spam-8x thread.archive dispatch -> thread.archived: 5.71ms / 50.80ms -> 0.93ms / 17.98ms
  • create-turn-spam-8x thread.create dispatch -> thread.created: 3.61ms / 58.38ms -> 2.44ms / 67.52ms
  • this helped archive latency materially, but did not improve the create tail consistently

Testing

  • bun run --cwd apps/server test src/orchestration/Layers/CheckpointReactor.test.ts
  • bun run --cwd apps/server test:perf
  • bun run fmt .
  • bun run lint
  • bun run typecheck

Stacked on #1669.


Note

Medium Risk
Changes the event triggers used to capture pre-turn checkpoint baselines; if thread.turn-start-requested is not emitted in some flows, baseline capture could be skipped and later diff/capture paths may degrade or log warnings.

Overview
Reduces CheckpointReactor domain-event fanout by no longer enqueueing or processing thread.message-sent events, relying solely on thread.turn-start-requested to ensure the pre-turn baseline checkpoint exists.

This narrows ensurePreTurnBaselineFromDomainTurnStart to accept only thread.turn-start-requested and updates the domain event stream filter accordingly, cutting work from the reactor’s hot path.

Written by Cursor Bugbot for commit b24b5fb. This will update automatically on new commits. Configure here.

Note

Remove thread.message-sent events from CheckpointReactor stream fanout

The CheckpointReactor was routing thread.message-sent events to ensurePreTurnBaselineFromDomainTurnStart, but this path was always short-circuited by an early-return guard. This refactor removes that dead code path entirely, narrowing the event filter and dispatch logic in CheckpointReactor.ts to only handle thread.turn-start-requested, thread.checkpoint-revert-requested, and thread.turn-diff-completed.

Macroscope summarized b24b5fb.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4a577b43-375d-430f-a605-f74bd121c047

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/perf-checkpoint-reactor-fanout

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Apr 2, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 2, 2026

Approvability

Verdict: Needs human review

This PR removes 'thread.message-sent' as a trigger for the checkpoint reactor, changing when checkpoints are created. While the author is the primary contributor to this file and the intent is performance optimization, this is a meaningful change to core orchestration behavior that warrants human verification of the intended semantics.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant