deno
e375202b - perf(ext/websocket): integrate fastwebsockets PR #133 ServerEngine read path

Commit
150 days ago
perf(ext/websocket): integrate fastwebsockets PR #133 ServerEngine read path Per Divy's scope correction on issue #169: the previous version of this PR only swapped the write side to \`try_write\` / \`try_write_vectored\` and kept reads on \`fastwebsockets::WebSocketRead\`. The original ask was to integrate PR #133's ServerEngine optimizations, especially the read path, into Deno's WebSocket implementation and benchmark it. This commit does that. The fast-TCP read side now drives an inline framing engine directly: - One scratch buffer per resource (initial 64 KiB, growable to 64 MiB) - \`fastwebsockets::parse_header\` for header parsing — the public sync entry point added by PR #133 - \`fastwebsockets::unmask\` for in-place SIMD unmask - Control-frame replies use the in-place outbound-segment trick from \`ServerEngine::process_into\`: the response header goes into the input frame's freed-up mask slot and the whole \`[response_header || payload]\` ships as one contiguous \`try_write\` (no allocation, no scatter/gather, one \`send()\` syscall) - Fragmentation reassembly handled in the same loop against the bounded \`max_message_size\` (\`ServerEngine\` itself doesn't reassemble; the engine surface this hand-rolls) - Pong frames surfaced to JS so server-side idle-timeout heartbeats still work - No \`WebSocketRead::read_frame\` per-frame Future state machine - No \`BytesMut::split_to\` per frame - No \`FragmentCollectorRead\` wrapper The previous commit's TCP read/write sharing via \`Rc<TcpStream>\` (which avoids \`OwnedWriteHalf::drop\`'s extra \`shutdown(SHUT_WR)\`) is preserved. User-initiated sends from \`op_ws_send_*\` / \`op_ws_close\` still go through \`try_write\` / \`try_write_vectored\`. Other transports (TLS / H2 / Unix / vsock / tunnel) keep the existing \`fastwebsockets::WebSocket\` path unchanged. \`DENO_WS_DISABLE_FAST_TCP=1\` forces them back on globally. Co-Authored-By: Divy Srivastava <me@littledivy.com>
Author
Committer
Parents
Loading