From 37c17804dfd750475feb04f2fed212f9efaf5209 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 16 Jun 2025 18:51:59 +0200 Subject: [PATCH] libstore: serialize wire messages into temp buffer once we make our socket fds non-blocking we won't be able to easily use plain FdSink for serialization. performance impact of using a temporary buffer should be low since we don't send very many messages and even in the simple local daemon case networking overhead is already quite high. Change-Id: I550d73142570b7d2e7b0feb1bcc57d61e9b45178 --- lix/libstore/remote-store-connection.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lix/libstore/remote-store-connection.hh b/lix/libstore/remote-store-connection.hh index 8c730b014..9d16fe9e0 100644 --- a/lix/libstore/remote-store-connection.hh +++ b/lix/libstore/remote-store-connection.hh @@ -161,7 +161,9 @@ struct RemoteStore::ConnectionHandle // and serialize all *preceding* arguments normally before handing over to // the subframing layer (which is then responsible for any error handling) if constexpr (requires { *handle->to << std::declval(); }) { - ((*handle->to << std::forward(args)), ...); + StringSink msg; + ((msg << std::forward(args)), ...); + StringSource{msg.s}.drainInto(*handle->to); handle->to->flush(); LIX_TRY_AWAIT(processStderr()); } else { @@ -169,10 +171,12 @@ struct RemoteStore::ConnectionHandle AllArgsT allArgs(std::forward(args)...); [&](std::integer_sequence) { - ((*handle->to << std::forward>( + StringSink msg; + ((msg << std::forward>( std::get(allArgs) )), ...); + StringSource{msg.s}.drainInto(*handle->to); handle->to->flush(); }(ImmediateArgsIdxs{});