fix: remove quadratic router payload processing - #1326
Merged
Merged
Conversation
|
The PR is not yet safe to merge because valid colon-prefixed schema properties can no longer receive deterministic argument repairs. Reviews (1) · Last reviewed commit: "Remove quadratic router payload processi..." |
makosblade
force-pushed
the
fix/linear-payload-processing
branch
from
September 15, 2026 19:54
e7f258a to
20325d6
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 20325d6. Configure here.
makosblade
force-pushed
the
fix/linear-payload-processing
branch
from
September 15, 2026 22:54
953cabe to
43f5096
Compare
Co-Authored-By: Weave Router <router@workweave.ai>
makosblade
force-pushed
the
fix/linear-payload-processing
branch
from
September 15, 2026 23:01
43f5096 to
8100c95
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Four request-processing paths did repeated work proportional to payload size, so cost grew quadratically:
An earlier version of this PR fixed the speed but introduced two behavior regressions (nested-union repairs lost edits; empty assistant shells stopped being dropped) and left member lookup quadratic.
Solution
sse.Scanner: a per-buffer cursor that resumes the delimiter search where the last write left off. Zero-alloc, same LF/CRLF grammar. Wired into all 18 buffered consumers with their existing reset/EOF semantics.Impact
Medians of 10 runs, base vs this branch, Apple M4 Pro.
Nominal request sizes (what most traffic looks like):
Large inputs (the quadratic cases): tool-arg repair 36–134× faster at 16k fields; SSE 13× at 1 MiB; Responses cleanup 84–178× at 1k messages.
The one cost: tiny repairs (1–8 fields) pay ~1–3 µs of index setup. Everything else is neutral or faster.
Verification
diagnostic-loggingfindings are on pure JSON helpers with no external calls and were declined per that check's scope exclusion.Local Docker was unavailable, so replay-smoke relies on CI.
🤖 Generated with Weave Router