From d5cfc6f19ce11408e7c71fa2cad29302cb856daf Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 1 Aug 2025 01:10:50 +0200 Subject: [PATCH] libstore/remote: frame buffers, don't buffer frames shoving a nar dump directly into a framed sink created a bunch of tiny frames, each of which requires at least two syscalls to read. this can lead to immense performance loss when using a daemon; we have seen 15% in benchmarks on main and even more with async code involved ... oops. Change-Id: I8529506e3de74d92834d1f4ee228dcaf32eb756c --- lix/libstore/remote-store.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lix/libstore/remote-store.cc b/lix/libstore/remote-store.cc index 8612dc7cd..a18a5720c 100644 --- a/lix/libstore/remote-store.cc +++ b/lix/libstore/remote-store.cc @@ -834,15 +834,15 @@ kj::Promise> RemoteStore::ConnectionHandle::withFramedStream( std::function>(AsyncOutputStream & stream)> fun ) try { - AsyncBufferedOutputStream to(stream); - AsyncFramedOutputStream sink(to); + AsyncFramedOutputStream framed(stream); + AsyncBufferedOutputStream sink(framed); // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) auto send = [&]() -> kj::Promise> { try { TRY_AWAIT(fun(sink)); - TRY_AWAIT(sink.finish()); - TRY_AWAIT(to.flush()); + TRY_AWAIT(sink.flush()); + TRY_AWAIT(framed.finish()); co_return result::success(); } catch (...) { handle.markBad();