limit batch size in main loop#203
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: get-convex/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refines the job-processing loop's batching strategy and cursor-recovery mechanism in src/component/loop.ts. It introduces a MAIN_BATCH_SIZE constant to cap per-iteration completion and start processing, preventing unbounded writes while preserving throughput through rapid re-firing. The cursor scan buffer is tightened by reducing CURSOR_BUFFER_SEGMENTS, narrowing how far behind the current position the loop looks for out-of-order commits. The main function now explicitly branches between recovery iterations (which scan from the beginning with zeroed cursors) and normal iterations (which use offset cursors). Instrumentation is enhanced with stage-specific and recovery-state-aware timing labels, plus a new debug log for idle transitions. Sequence Diagram(s)sequenceDiagram
participant LoopMain as Loop.main
participant Snapshot as SnapshotQuery
participant Pending as getPending
participant Start as handleStart
participant Status as runStatus
LoopMain->>Snapshot: request snapshot (isRecoveryIter ? zeroed cursors : offset cursors)
Snapshot-->>LoopMain: snapshot results
LoopMain->>Pending: fetch pending (cap by MAIN_BATCH_SIZE)
Pending-->>LoopMain: pending completion/cancel/start lists
LoopMain->>Start: process each start (console.time labeled by pending starts)
Start-->>LoopMain: start handled
LoopMain->>Status: patch runStatus -> scheduled/idle (console.debug)
Status-->>LoopMain: patched
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
36962e9 to
4ad9d7f
Compare
4ad9d7f to
3df8a63
Compare
There was a problem hiding this comment.
could consider reusing isRecoveryIter here
3df8a63 to
8dedad3
Compare

Two optimizations: