Skip to content

search: attribute permit-wait latency to the blocking resource - #6589

Draft
loutPhilipps wants to merge 1 commit into
lout.philipps/span-attributesfrom
lout.philipps/permit-wait
Draft

search: attribute permit-wait latency to the blocking resource#6589
loutPhilipps wants to merge 1 commit into
lout.philipps/span-attributesfrom
lout.philipps/permit-wait

Conversation

@loutPhilipps

@loutPhilipps loutPhilipps commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

acquire_leaf_split_search_permit (renamed from waiting_for_leaf_search_split_semaphore in #6620) was a bare timer, so a long wait couldn't be attributed to the two things a split-search permit can block on: warmup/download slots or the memory budget.

The actor now tracks the resource blocking the head of the queue in a shared BlockReasonHandle (an atomic). Because permits are served in order, whatever blocks the head blocks every waiter, so this queue-level reason is correct for a waiter at any position. Each SearchPermitFuture reads the handle, and a drop guard (WaitBlockReasonRecorder) on the wait span records blocked_on when the wait ends — granted or cancelled — gated on the wait being long (≥1ms) so instant grants stay unlabeled. Attributing on the wait side (not from the granted permit) is what lets the long, deadline-cancelled waits — the ones we care about — carry a reason even though they never get a permit.

Stacked on #6588.

🤖 Generated with Claude Code

@loutPhilipps
loutPhilipps force-pushed the lout.philipps/span-attributes branch from 248f437 to ecb2499 Compare July 21, 2026 12:46
@loutPhilipps
loutPhilipps force-pushed the lout.philipps/permit-wait branch from fd04918 to 67a3ded Compare July 24, 2026 10:01
waiting_for_leaf_search_split_semaphore was a bare timer, so a long
wait couldn't be attributed to the two things a split-search permit
can block on: warmup/download slots or the memory budget.

The actor now tracks the resource blocking the head of the queue in a
shared BlockReasonHandle (an atomic). Because permits are served in
order, whatever blocks the head blocks every waiter, so this
queue-level reason is correct for a waiter at any position. Each
SearchPermitFuture reads the handle, and a drop guard
(WaitBlockReasonRecorder) on the wait span records blocked_on when the
wait ends -- granted or cancelled -- gated on the wait being long
(>=1ms) so instant grants stay unlabeled. Attributing on the wait side
(not from the granted permit) is what lets the long, deadline-cancelled
waits -- the ones we care about -- carry a reason even though they
never get a permit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@loutPhilipps
loutPhilipps force-pushed the lout.philipps/span-attributes branch from ecb2499 to a464de8 Compare July 24, 2026 12:37
@loutPhilipps
loutPhilipps force-pushed the lout.philipps/permit-wait branch from 67a3ded to c685f93 Compare July 24, 2026 12:37
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