Skip to main content

MAX_UNARY_SCAN_QUADS

Constant MAX_UNARY_SCAN_QUADS 

Source
pub const MAX_UNARY_SCAN_QUADS: usize = _; // 29_330usize
Expand description

Ceiling for “provably small” unlimited scans that may take the unary ScanPattern RPC (one round trip) instead of the storage-driven ScanPatternStream endpoint. Derived, not chosen: the worst-case serialized row is waratah_proto::WORST_CASE_QUAD_WIRE (143 bytes — four max-width encoded terms plus proto framing, pinned by a test against the real encoder), so one waratah_proto::GRPC_MAX_MESSAGE_SIZE message holds at most this many rows no matter what data the encoder produces. The value sits at the exact floor of that division by design — worst-case means the message may be full to the last varint.

Deliberately decoupled from GROUP_FOLD_BATCH: the aggregate executor’s larger pages stream their rows and must not raise this unary ceiling.

Used by: scan_page_at’s unbounded-demand decision (limit == 0: prove the result ≤ this via unary_scan_quads_bound to take one unary message, else drain the stream) and the ResourceExhausted escalation fallback for a mis-proven bound.

Changing it affects: how often an unbounded scan takes one unary round trip vs the streaming endpoint. Raising it past the division result is not possible without widening the message limit or shrinking the term encoding; lowering it is a policy choice that sends more drains to the stream endpoint.

Relationship to SCAN_BATCH: that constant sizes compute-side page demand; this one sizes the unary transport ceiling. The mainline self-checks — fetch_window compares every demand against this constant — but the direct-unary exceptions page at SCAN_BATCH, so a retune of this constant below SCAN_BATCH pushes those pages into the escalation path (correct, but every such page pays a wasted oversized attempt first). Prefer retuning upward, toward the message-size bound.