Skip to content

Deforkify - #1

Draft
guybedford wants to merge 2 commits into
danlapid:mainfrom
guybedford:deforkify
Draft

Deforkify#1
guybedford wants to merge 2 commits into
danlapid:mainfrom
guybedford:deforkify

Conversation

@guybedford

@guybedford guybedford commented Sep 11, 2026

Copy link
Copy Markdown

Simplification of the patch set to just the current in-progress upstream PRs ready to land. In particular no longer relying on the hosted runtime behavior of JSPI IO under callbacks: Pumpkin runs bottom-up on stock Tokio under JSPI, with -sREENTRANT_JSPI giving each activation its own shadow stack.

Removed:

  • the tokio HostedRuntime fork (emscripten-layering) and the future_to_promise adapter; Tokio is the upstream scheduler, timers and I/O driver
  • the injected-stream connection entry point in the Pumpkin patch (serve_connection, from_stream, boxed reader/writer types); Pumpkin runs its stock accept loop
  • the workers-rs dependency and its patch (workers-rs-emscripten-toolchain.patch)
  • the wasm-streams dependency
  • the wasm-bindgen fork, its patch (wasm-bindgen-emscripten-closures.patch) and toolchain/wasm-bindgen.Cargo.lock; the 0.2.128 release CLI runs as an emcc post-link step under -sWASM_BINDGEN
  • the emscripten fork frontend; upstream main plus the open PRs below, with the paired emscripten-releases LLVM through emsdk and Binaryen built from the jspi-hooks branch (setup does both)
  • the libc fork; mio and the application share rust-lang/libc libc-0.2
  • the nightly toolchain pin; Rust beta (1.99) suffices with no #![feature]

PR branches referenced directly

This builds on top of and requires cloudflare/workerd#7306 (net.Server, per-Durable-Object port tables, connectHandler/handleAsNodeConnection) on top of merged cloudflare/workerd#7299, to support the ability to treat incoming connections as file descriptor sockets. cloudflare/workerd#7313 removes the spurious Uncaught Error: Network connection lost. logged at connect handler completion.

To run - same instructions as the README, plus building workerd from cloudflare/workerd#7306 (with #7313 applied), and referencing it via MINIFLARE_WORKERD_PATH=../workerd/bazel-bin/src/workerd/server/workerd npm run dev on start. npm test passes end to end against that build from a clean .work/ provision.

Posting as a draft, pending cloudflare/workerd#7306 being merged.

Drop the wasm-streams checkout and cdylib patch in favor of
guybedford/wasm-streams (MattiasBuelens/wasm-streams PR pending). The
socket2 git rev was exactly the v0.6.5 release.
One perpetual `#[wasm_bindgen(jspi)]` export builds a current-thread
runtime and `block_on`s the whole server lifetime; every park suspends the
Wasm stack on `epoll_wait`, so the hosted runtime adapter is gone. Pumpkin
binds its stock `TcpListener` on 25565 inside the Durable Object's port
table, and the object routes each inbound socket to it with
`handleAsNodeConnection`, replacing the injected-stream entry point,
wasm-streams, and the workers-rs dependency. `stop` cancels the server and
the run promise settling is the checkpoint signal. `-sREENTRANT_JSPI`
gives each activation its own shadow stack, so other entries into the
module while the server is suspended cannot clobber its frames.

Toolchain: Rust beta; emscripten main plus the JSPI hooks, reentrant JSPI
and epoll listener PRs, with the paired emscripten-releases LLVM and the
jspi-hooks Binaryen branch built by setup; wasm-bindgen 0.2.128 CLI via
`-sWASM_BINDGEN`; exnref exception handling throughout; tokio
`emscripten-epoll`, mio tokio-rs/mio#1969, libc `libc-0.2`. rustc needs a
larger compile-thread stack for pumpkin-data. The wasm-bindgen and
workers-rs patches and the CLI lockfile are gone; the Pumpkin patch drops
the injected-stream entry point.

Requires a workerd with per-Durable-Object port tables and `net.Server`
inbound routing (`MINIFLARE_WORKERD_PATH`). CI moves to Linux.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant