Skip to content

starknet_transaction_prover: track saturation and queue depth on the request path - #15027

Open
avi-starkware wants to merge 1 commit into
avi/prover-v3/panic-counterfrom
avi/prover-v3/saturation-tracker
Open

starknet_transaction_prover: track saturation and queue depth on the request path#15027
avi-starkware wants to merge 1 commit into
avi/prover-v3/panic-counterfrom
avi/prover-v3/saturation-tracker

Conversation

@avi-starkware

Copy link
Copy Markdown
Collaborator

Adds the state /health will read in the next PR: a SaturationMonitor that
opens a window on the first busy-reject and closes it on any forward progress --
a request acquiring a worker slot, or a slot being released. Slot release has to
count, because once 503 pulls the load balancer's traffic away, a clear that
waited for a new request would latch 503 forever; a drop guard covers the
success, error and client-disconnect exits alike.

Both busy-reject arms go through record_busy_reject, which counts the outcome,
opens the window, warns and returns -32005 together, so a reject cannot count
without latching. Also exposes queue depth and queue-wait duration, bucketed at
the wait timeout.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

avi-starkware commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes admission/queue behavior instrumentation and shared RPC construction (from_config now takes SaturationMonitor); reject paths and drop ordering affect overload signaling, though successful proving paths are unchanged aside from metrics and guards.

Overview
Adds a SaturationMonitor on the proving request path so a follow-up can drive /health from sustained overload: the window opens on the first busy-reject (-32005) and clears on forward progress (worker slot acquired or released via RAII SaturationClearGuard), with careful drop ordering so slot release cannot leave a stale saturation latch.

Busy-rejects (queue full vs queue wait timeout) now share record_busy_reject, which increments prover_prove_transaction_outcome_total with rejected_queue_full / rejected_wait_timeout, opens the saturation window, and logs—so counting and saturation stay aligned.

Observability: prover_queue_waiting_requests and prover_queue_wait_duration_seconds (with tuned histogram buckets) track FIFO wait behind worker slots; README and exporter pre-registration are updated accordingly. Tests cover reject paths, gauge behavior, and saturation window semantics without a full prove run.

Reviewed by Cursor Bugbot for commit f6e04fe. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1d3075e. Configure here.

// worker slot before `_saturation_clear_guard` clears the window. The reverse order would
// let a rejection open a new window between the clear and the release, with nothing left
// to clear it.
let (_saturation_clear_guard, _permit) = self.acquire_worker_slot().await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saturation latch on admission drop order

Medium Severity

_admission is declared before the clear guard, so it drops after mark_progress. A concurrent queue-full reject can reopen the saturation window in that gap with no SaturationClearGuard left to clear it. With max_queued_requests = 0 and max_concurrent_requests = 1, admission stays full until that late drop, so the window can latch open once load-balancer traffic drains — the failure mode this binding order was meant to prevent.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1d3075e. Configure here.

@avi-starkware
avi-starkware force-pushed the avi/prover-v3/panic-counter branch from d3fe724 to e1815f6 Compare August 25, 2026 19:09
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/saturation-tracker branch 2 times, most recently from 9496ef5 to 6775092 Compare August 26, 2026 09:54
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/panic-counter branch 2 times, most recently from 57ee518 to 4523a54 Compare August 26, 2026 13:15
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/saturation-tracker branch 2 times, most recently from 1d0384a to 738780b Compare August 26, 2026 13:39
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/panic-counter branch from 4523a54 to 7040fc6 Compare August 26, 2026 13:39
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/saturation-tracker branch from 738780b to 22df80d Compare August 26, 2026 14:04
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/panic-counter branch from 7040fc6 to 40c5031 Compare August 26, 2026 14:04
…request path

Adds the state `/health` will read in the next PR: a `SaturationMonitor` that
opens a window on the first busy-reject and closes it on any forward progress --
a request acquiring a worker slot, or a slot being released. Slot release has to
count, because once 503 pulls the load balancer's traffic away, a clear that
waited for a new request would latch 503 forever; a drop guard covers the
success, error and client-disconnect exits alike.

Both busy-reject arms go through `record_busy_reject`, which counts the outcome,
opens the window, warns and returns -32005 together, so a reject cannot count
without latching. Also exposes queue depth and queue-wait duration, bucketed at
the wait timeout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/saturation-tracker branch from 22df80d to f6e04fe Compare August 26, 2026 15:39
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.

2 participants