Batch completion: probe from the newest tracking row (3/3, no measured gain) - #10
Open
jpcamara wants to merge 1 commit into
Open
Batch completion: probe from the newest tracking row (3/3, no measured gain)#10jpcamara wants to merge 1 commit into
jpcamara wants to merge 1 commit into
Conversation
A batch drains roughly in id order, so the rows still outstanding are at the end of the range while the beginning is whatever finished jobs left behind. In isolation this halves the probe's tail latency (p95 2.49ms to 0.68ms on a 95%-drained batch). It did not move the end-to-end drain: 318s against 320s on a 120k batch, which is inside the run-to-run noise. Kept for the tail behaviour, but on this evidence it is not what is holding the completion path back. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 3 of 3. Builds on #9. This one did not pay off end to end — opening it for the record rather than to argue for it.
The idea
A batch drains roughly in id order, so the tracking rows still outstanding are at the end of the range while the beginning is whatever finished jobs left behind. Scanning the completion probe from the newest row should skip the emptied region — the same dynamic behind claim cursors.
In isolation it works
On a 95%-drained 200k batch:
exists?(as written)id ASCid DESCTail latency drops by roughly 3.7×.
End to end it doesn't
120k-job batch: 318s against 320s — inside run-to-run noise. The probe isn't what's holding the completion path back once stack 2 has removed the extra round trip.
Worth keeping only if the tail behaviour is valued on its own; otherwise this can be dropped and stack 2 delivers the same result in two commits and about 20 lines.
Testing
Batch suites green on SQLite and PostgreSQL. RuboCop clean.