Repository navigation
perf(devin): batch consumed stream chunk removal - #8049
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked. Hygiene✅ Deterministic PR hygiene checks passed. |
# Conflicts: # structure/transports/byte-accounting.md
# Conflicts: # structure/transports/byte-accounting.md
|
Maintainer integration into perf(devin): batch consumed stream chunk removal. A maintainer merge of current
Thanks for the fix. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Devin Connect-RPC buffers a fragmented frame as a queue of chunks. When the frame becomes complete,
drop()currently callsArray.shift()for each fully consumed chunk. A 64 KiB text frame delivered in four-byte reads caused 16,388 queue-prefix removal calls in the realstreamChatEventsparser.Compact surviving chunks in place with
copyWithinand length truncation, or clear the queue when no bytes remain. This avoids allocating an unused removed-chunk result array. Keep a partial head as its existing slice and preserve every later chunk in order. The operation-count regression bounds the same input to at most eight prefix-removal calls, observingshift,spliceandcopyWithinrather than depending on CPU speed.drop()helper and its nearby queue comment insrc/adapters/devin/cloud-direct/chat.ts.drop()bodies, draining 65,536 four-byte chunks (256 KiB) while retaining a 16-byte suffix took a five-sample median 11.8604 ms -> 1.0870 ms (about 10.9x shorter). Both versions retained exactly 16 bytes in one chunk. This measures queue drainage only, not provider inference, total response latency, or RSS. The durable regression asserts operation counts; it has no timing threshold and makes no runtime-specific Big-O claim aboutArray.shift.Duplicate searches covered open and closed issues/PRs for Devin queue, stream, fragmentation, Connect chunks, cloud-direct performance and
chunkQueue.shift. No equivalent change or existing PR for this branch was found. Related results #4450 concern response-header deadlines and #6344 concern late reasoning signatures; they address different behavior. This change is independently implemented.Verification
Initial verification head:
24119a360e7e288ea364a5b9d2bd19e1db145193(current-head follow-up below). Base:devat63de499e1. Native Windows, Bun 1.4.4. The fetched base is current and the committed worktree is clean.bun test tests/providers/devin-stream-queue.test.ts --timeout 30000: 6 passed / 1 failed, 8 assertions. Output/framing cases passed; the work-count assertion failed with 16,388 prefix removals against an upper bound of eight.bun test --isolate tests/providers/devin-stream-queue.test.ts tests/providers/devin-hardening.test.ts tests/providers/devin-stream-deadline.test.ts tests/providers/devin-chat-wire-fixes.test.ts --timeout 30000: 125 passed / 0 failed, 431 assertions.bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts --timeout 30000: 38 passed / 0 failed, 664 assertions. Both explicit layout mappings and the existing file-size ceilings pass.bun run typecheck: passed; no type errors in 2,253 files.bun run structure:check: passed with the new test staged for index-based path validation.bun run privacy:scan: passed.git diff --cached --checkbefore commit andgit diff upstream/dev...HEAD --checkafter commit: passed.Applied test-design-guard to deterministic work bounds and framing preservation. The tests use a synthetic inference executor, explicit unavailable-catalog state and restored JWT opt-in environment state; no provider credential or live provider request is used.
Full-suite scope exception: local full-suite and broad import-connected
test:changedruns were not performed. The cloud-direct adapter's shared imports reach wider provider, OAuth and bridge integrations, making that run disproportionate for this private queue-helper change on this Windows host. Four focused runtime/provider files and three source-as-data layout/ratchet files were exercised explicitly above. Broader integration and platform coverage remain for repository CI; no hosted CI result is claimed as passing. No workflow dispatch or rerun was initiated.Author review follow-up
Current exact head:
36f795edc054c4f34df77ee50b0de4c84da21474.splicecreates an unused array containing the removed chunk references. UsecopyWithinfollowed by length truncation to compact survivors in place. Keep the full-drain clear, partial-head slices and subsequent frame order unchanged; update the owning contract.copyWithinas well asshift/spliceand count removed-result array slots. Against24119a360,bun test tests/providers/devin-stream-queue.test.ts --test-name-pattern 'bounded queue-prefix' --timeout 30000failed at the intended assertion: 16,387 discarded chunk-reference slots instead of zero, while the removal-call bound passed. This is allocation regression evidence, not a process-RSS measurement.bun test --isolate tests/providers/devin-stream-queue.test.ts tests/providers/devin-hardening.test.ts tests/providers/devin-stream-deadline.test.ts tests/providers/devin-chat-wire-fixes.test.ts --timeout 30000: 125 passed / 0 failed, 432 assertions. The test asserts zero discarded-result slots and at most eight prefix-removal calls, plus intact output.bun run typecheck: passed, no type errors in 2,253 files.bun run structure:checkandbun run privacy:scan: passed. Diff whitespace checks passed.dropcomparison against the original dev helper with the current implementation: 65,536 four-byte chunks plus a retained 16-byte suffix, five samples per version, medians 11.8604 ms -> 1.0870 ms. Both versions retain exactly the same suffix. These current measurements replace the first implementation's timing in Summary; no whole-response speedup is claimed.Applied test-design-guard to allocation evidence and framing preservation. Layout mappings are unchanged by this follow-up, so their preceding 38 passing checks were not repeated. The documented full-suite exception remains; hosted results must cover this new exact head independently. No live provider request, workflow dispatch or rerun was initiated.
Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit