-
Notifications
You must be signed in to change notification settings - Fork 5.8k
perf: fast wasm streaming #31289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
perf: fast wasm streaming #31289
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes WASM streaming performance by replacing manual chunk-by-chunk feeding with a more efficient stream-based approach. The changes align with deno_core PR #1243 and move WASM data streaming from JavaScript to a native operation.
- Refactored
handleWasmStreamingto useop_wasm_streaming_stream_feedinstead of manually reading and feeding chunks - Added logic to detect and reuse resource-backed streams when available
- Updated dependencies to use a local deno_core patch for testing
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ext/fetch/26_fetch.js | Refactored WASM streaming to use the new op_wasm_streaming_stream_feed operation, eliminating the manual reader loop and adding resource backing detection |
| Cargo.toml | Added path-based patch for local deno_core development |
| Cargo.lock | Updated dependency entries to reflect the local deno_core patch and related dependency changes (proc-macro-rules removed, syn-match added) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cargo.toml
Outdated
| opt-level = 3 | ||
|
|
||
| [patch.crates-io] | ||
| deno_core = { path = "../deno_core/core" } |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Cargo.toml patch should not be committed to production code. Path-based patches are typically used for local development and testing. This should either be removed before merging or replaced with a proper git or version-based dependency once the corresponding deno_core changes are published.
| deno_core = { path = "../deno_core/core" } |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughA patch override redirects Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
Cargo.toml (1)
533-535: Treat thedeno_coregit patch as temporary and clean it up before/after landingThe
[patch.crates-io]override is fine for cross-repo development, but it should not be left as a long‑term override inmain. It silently replaces the pinned crates.io version in[workspace.dependencies]and can surprise downstream consumers.Once the
deno_corechanges are released, please either:
- Bump
deno_corein[workspace.dependencies]to the new published version and remove this patch, or- Otherwise ensure this patch is strictly temporary and not kept in production builds.
A follow‑up PR or a TODO comment pointing to the cleanup would also help avoid it sticking around.
-[patch.crates-io] -deno_core = { git = "https://github.com/denoland/deno_core", rev = "70c2762" } +## Temporary override for in-flight deno_core changes used by fast wasm streaming. +## Remove once a crates.io release including op_wasm_streaming_stream_feed is available. +#[patch.crates-io] +#deno_core = { git = "https://github.com/denoland/deno_core", rev = "70c2762" }
🧹 Nitpick comments (1)
ext/fetch/26_fetch.js (1)
580-605: Wasm streaming resource wiring looks correct; consider unrefable backing parityThe new
handleWasmStreaminglogic correctly:
- Validates the
Response,- Reuses an existing readable stream resource backing when available (
getReadableStreamResourceBacking),- Falls back to
resourceForReadableStreamwithautoClose = truewhen there is no backing, and- Lets
op_wasm_streaming_stream_feed(rid, streamRid, autoClose)manage the feed and cleanup viaclose/abort.This looks functionally sound and avoids the per‑chunk JS loop.
If you want to mirror
ext/web/06_streams.jsmore closely and also reuse unrefable stream backings, you could optionally:
- Import
getReadableStreamResourceBackingUnrefablefromext:deno_web/06_streams.js, and- Use the combined pattern:
-import { - errorReadableStream, - getReadableStreamResourceBacking, - readableStreamForRid, - ReadableStreamPrototype, - resourceForReadableStream, -} from "ext:deno_web/06_streams.js"; +import { + errorReadableStream, + getReadableStreamResourceBacking, + getReadableStreamResourceBackingUnrefable, + readableStreamForRid, + ReadableStreamPrototype, + resourceForReadableStream, +} from "ext:deno_web/06_streams.js";- const resourceBacking = getReadableStreamResourceBacking( - innerResponse.body?.stream, - ); + const stream = innerResponse.body?.stream; + const resourceBacking = + getReadableStreamResourceBacking(stream) ?? + getReadableStreamResourceBackingUnrefable(stream);This is a minor parity tweak; the current implementation is otherwise solid.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
Cargo.toml(1 hunks)ext/fetch/26_fetch.js(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
ext/fetch/26_fetch.js (1)
ext/web/06_streams.js (3)
res(793-793)resourceBacking(1095-1096)rid(899-901)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: test release linux-x86_64
- GitHub Check: test debug linux-aarch64
- GitHub Check: test debug macos-aarch64
- GitHub Check: test debug linux-x86_64
- GitHub Check: test debug windows-x86_64
- GitHub Check: test debug macos-x86_64
- GitHub Check: build libs
- GitHub Check: lint debug macos-x86_64
- GitHub Check: lint debug windows-x86_64
- GitHub Check: lint debug linux-x86_64
🔇 Additional comments (1)
ext/fetch/26_fetch.js (1)
15-20: Import ofop_wasm_streaming_stream_feedmatches the new streaming pathSwitching the import to
op_wasm_streaming_stream_feedaligns with the new streaming implementation below; no issues from this side.
Ref denoland/deno_core#1243