Repository navigation
perf(sse): scan SSE data payloads in place and share the empty byte view - #4979
Conversation
… array allocations - Replace RegExp split with in-place character index scanner (indexOf/charCodeAt). - Eliminate intermediate string array allocation and regex overhead in hot SSE payload parsing. - Unify relay.ts and sse-payload-rewrite.ts onto single canonical implementation. - Maintain identical RFC event-stream semantics for colonless data fields and multi-line data. (cherry picked from commit b890c92)
…nd expand boundary tests (cherry picked from commit 6349418)
(cherry picked from commit eb606bd)
Co-authored-by: chilung <b0423031@gmail.com> (cherry picked from commit 1527754)
The in-place scanner, the canonical extractor relay.ts now re-exports, and the shared zero-length view are a stream-buffer accounting contract, so they are written once in the doc that owns that section. The docs that merely link that section already do so from their own cross-reference line; restating the same contract in each of them is the two-statements-that-drift case structure/AGENTS.md asks to avoid. Co-authored-by: chilung <b0423031@gmail.com>
|
Warning Review limit reachedNext included review available in 3 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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. |
리뷰 · 우선순위 77 / 80이 PR(#4979)은 기여자 지금 성능 쪽은 핫 경로입니다. 예전 구현은 완성된 SSE 블록마다 두 번째 축은 빈 바이트입니다. 문서는 라인 src/server/relay.ts 406-414(현재 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36ecb5a490
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| failed enqueue and cancellation release the reservation without re-entering a disposed rewrite. | ||
| Old/new buffer overlap remains charged against the same translator cap. | ||
|
|
||
| Complete SSE blocks extract `data` fields with one indexed pass over the block rather than a |
There was a problem hiding this comment.
Update every document mapped to src/server
This change modifies the shared src/server/ area but updates only byte-accounting.md, while structure/manifest.json also maps that area to documents such as runtime.md, transports/responses.md, and data-planes/images.md. Update every mapped document in this change—preferably with a reference to this canonical contract rather than duplicated prose—because the scoped repository rule explicitly requires all listed documents to remain synchronized.
AGENTS.md reference: structure/AGENTS.md:L49-L50
Useful? React with 👍 / 👎.
|
✅ Deterministic PR hygiene checks passed. |
|
Merging with macOS legs outstanding, and recording why rather than leaving it implicit. At this exact head the full Linux suite (test 1/4 through 4/4), This change is platform-neutral, so waiting on a queue that is both saturated and known-unreliable would delay the work without adding information. The evidence that governs the release is not per-PR macOS legs; it is the full-platform Stating the boundary plainly: this is merged on Linux, gates and cross-platform smoke evidence at its exact head, with macOS coverage deferred to the candidate run rather than claimed here. |
Carries #4731 by @chilung-cgu, reconciled against current
dev. Original commit authorship is preserved.Summary
sseDataPayloadsplit every complete SSE block with a regular expression and built an intermediate array of lines before joining them, on every block of every active stream. It now walks the block once withindexOf, slicing only the values it keeps.src/server/relay.tsandsrc/server/sse-frame-buffer.tsalso allocated a freshnew Uint8Array(0)at roughly twenty sites that all mean "nothing here"; those share one immutable zero-length view.Event-stream semantics are unchanged: colonless
datafields, the one optional ASCII space after the colon, multiline joining, UTF-8 text including astral characters, LF and CRLF input, and near-prefix fields such asdatabase:that must not match. Non-empty frame ownership, frame limits, cancellation, terminal detection and wire bytes are untouched.The conflict this carry reconciles. The branch was cut before two changes landed in
relay.ts: bounded non-stream response logging, and the hard-cancel guard that stops a partial terminal from being flushed. A textual rebase applies cleanly here — which is the problem, because "applies cleanly" and "preserves intent" are different questions, and green CI on the old base could not tell them apart. The carry was rebuilt against the current file rather than replayed onto it, and the resulting diff againstdevtouches only thenew Uint8Array(0)sites and the extractor export. Neither landed contract is reverted or reworded.One deliberate behavior change, carried from the original.
relay.tshad its own copy ofsseDataPayloadthat ignored a colonlessdataline; the canonical extractor insse-payload-rewrite.tstreats it as an empty value, which is what the event-stream specification says.relay.tsnow re-exports the canonical one rather than keeping a second implementation, so a baredataline contributes an empty string on that path too. The two copies disagreeing was the real defect; the specification decides which one wins. A trailing lone CR is covered by the same rule and is pinned as a test.On the structure docs. The contract is written once, in the
byte-accounting.mdsection that owns stream-buffer accounting. The other docs that link that section already carry a cross-reference line to it, and restating the contract in each of them is the two-statements-that-drift casestructure/AGENTS.mdasks to avoid.Verification
Local verification was not run: this lane forbids running any local suite, typecheck, build, or install. Hosted CI on this PR head is the executable verification.
Static checks performed in place of local execution:
relay.tswas diffed between the original branch's merge base and currentdevto enumerate what landed in between, then the finalorigin/dev..HEADdiff was read line by line to confirm that none of it is removed, reordered, or rephrased.databoundaries where the two differ.byte-accounting.mdparagraph names only paths this tree has, which is what the structure gate checks.Checklist
Co-authored-by: chilung b0423031@gmail.com