#15446·dynamo

perf(router): batch output-block updates and apply decay once per chunk

Author: jthomson04Created Sep 30, 2026Updated Sep 30, 2026
Labelslanguage::rustperformance

Describe the Bug

Non-blocking performance follow-up to #14613. Keep the block-count correctness fix separate from this optimization. #14666 has merged and provides the direct-update path to extend.

When router_track_output_blocks=true and nvext.agent_hints.osl is supplied, each new output block causes set_unique_suffix_fractional to scan all output blocks for the request. For a grouped response, #14613 applies the same decay value once per new block.

The growing scan already exists for single-block streaming updates. This issue addresses the repeated identical scans within one response chunk. Output tracking is disabled by default; without the output-length hint, these decay scans do not run.

Steps to Reproduce

Source-derived scenario; no runtime reproduction or latency measurement has been performed:

  1. Enable output-block tracking and supply nvext.agent_hints.osl.
  2. Process a response chunk that crosses multiple block boundaries.
  3. Follow the per-block loop in RequestGuard through add_output_block to the decay scan.

Expected Behavior

Append all new blocks for a response chunk and apply its decay value once. Preserve the final accounting result, attempt checks, cleanup, and local-only output updates.

Actual Behavior

With n existing output blocks and k new blocks, the decay scans visit kn + k(k+1)/2 output blocks, plus repeated prompt-suffix work. A single decay scan would visit n+k output blocks. For n=0 and k=1024, that is 524,800 versus 1,024 output-block visits; these are source-derived operation counts, not benchmark results.

#14666 removes the actor command for output updates, but leaves this scan unchanged. The work runs directly on the request task under the sequence lock.

Proposed Scope and Validation

  • Pass the block count through the frontend wrapper and LocalScheduler to the sequence update. Use one booking check and lock acquisition, append the blocks, then apply decay and update load observations once.
  • Retain existing single-block interfaces as wrappers. Preserve #14666's direct-update path; no new actor command, HTTP/Python interface, or wire change is needed.
  • Extend existing tests for grouped accounting with decay, stale bookings, and cleanup. Run a small CPU benchmark with tracking enabled and with/without the output-length hint before making performance claims.
  • Removing the growing scan across all separate streaming chunks is outside this follow-up.

Environment

  • Review host: Ubuntu 24.04.4 LTS, x86_64; Python 3.12.3.
  • Dynamo source: #14613 at 9664347e6d4af1bfd180188271569564d13e01e1; #14666 reviewed at f1ffe12860cd9d63bc2658e6fa4a86a34e79a089 and confirmed merged as 99ae6e5b1c735e46f537379b88383b3eb3f4f0c9.
  • Runtime/container, CUDA, GPU, Kubernetes: N/A; source-only review, no deployment or inference workload was run.