From a12d72b180439f2b31c1677a5f74ba29e7394342 Mon Sep 17 00:00:00 2001 From: Milan Miladinovic Date: Fri, 27 Nov 2026 01:38:55 -0500 Subject: [PATCH] Send getHttpService() for pipelining only in RpcWorkerInterface RpcWorkerInterface::request() and connect() call EventDispatcher.getHttpService(), make one call on the HttpService it returns, and drop it. They never look at the result of getHttpService() itself, but because it was sent with send(), the dispatcher sent a Return for it and the caller a Release for the capability in it, on every hop between the two. Send it with sendForPipeline() instead. For a Durable Object fetch in the Workers runtime this takes one request from 17 Cap'n Proto messages per hop to 15. The HttpService capability no longer resolves, so calls on it are not path-shortened. It only ever carries the one request that is pipelined on it. Co-Authored-By: Claude Fable 5.2 --- src/workerd/io/worker-interface.c++ | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/workerd/io/worker-interface.c++ b/src/workerd/io/worker-interface.c++ index 3021eeb8142..9a97645a62f 100644 --- a/src/workerd/io/worker-interface.c++ +++ b/src/workerd/io/worker-interface.c++ @@ -437,7 +437,10 @@ kj::Promise RpcWorkerInterface::request(kj::HttpMethod method, const kj::HttpHeaders& headers, kj::AsyncInputStream& requestBody, Response& response) { - auto inner = httpOverCapnpFactory.capnpToKj(dispatcher.getHttpServiceRequest().send().getHttp()); + // The HttpService is used for this one request and then dropped, so the call that fetches it + // is sent for pipelining only: the dispatcher need not send its result back. + auto inner = httpOverCapnpFactory.capnpToKj( + dispatcher.getHttpServiceRequest().sendForPipeline().getHttp()); auto promise = inner->request(method, url, headers, requestBody, response); return promise.attach(kj::mv(inner)); } @@ -447,7 +450,8 @@ kj::Promise RpcWorkerInterface::connect(kj::StringPtr host, kj::AsyncIoStream& connection, ConnectResponse& tunnel, kj::HttpConnectSettings settings) { - auto inner = httpOverCapnpFactory.capnpToKj(dispatcher.getHttpServiceRequest().send().getHttp()); + auto inner = httpOverCapnpFactory.capnpToKj( + dispatcher.getHttpServiceRequest().sendForPipeline().getHttp()); auto promise = inner->connect(host, headers, connection, tunnel, kj::mv(settings)); return promise.attach(kj::mv(inner)); }