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 saturation state on the hot RPC path; reject counting and guard drop order affect operability signals ahead of health integration.

Overview
Adds SaturationMonitor state on the proving request path so a follow-up can distinguish sustained overload from one-off -32005 rejects. The window opens on the first busy-reject and clears on forward progress (worker slot acquired or released via SaturationClearGuard), with explicit ordering so slot release cannot leave saturation latched after traffic stops.

prove_transaction now routes both busy paths through record_busy_reject, which increments Prometheus outcome counters (rejected_queue_full, rejected_wait_timeout), opens saturation, logs, and returns -32005 together. While waiting for a worker, the service exposes prover_queue_waiting_requests (RAII gauge) and prover_queue_wait_duration_seconds on successful slot acquisition; proving duration histograms still exclude rejects. Metrics README and exporter pre-registration are updated accordingly.

Unit tests cover saturation timing, reject metrics, and guard/clear behavior without a full prove run.

Reviewed by Cursor Bugbot for commit 16eb35c. 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.
Releasing a worker slot has to count, because once 503 pulls traffic away a
clear that waited for a new request would latch 503 forever. Both reject arms go
through `record_busy_reject`. Queue depth and queue-wait are also exposed.

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