Skip to content

Batch completion: probe from the newest tracking row (3/3, no measured gain) - #10

Open
jpcamara wants to merge 1 commit into
batch-completion-fastpath-2from
batch-completion-fastpath-3
Open

Batch completion: probe from the newest tracking row (3/3, no measured gain)#10
jpcamara wants to merge 1 commit into
batch-completion-fastpath-2from
batch-completion-fastpath-3

Conversation

@jpcamara

@jpcamara jpcamara commented Aug 24, 2026

Copy link
Copy Markdown
Owner

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:

probe p50 p95
exists? (as written) 0.73ms 2.49ms
ordered id ASC 0.74ms 1.81ms
ordered id DESC 0.50ms 0.68ms

Tail 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.

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>
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