From 74bed64ade7f6a71a5c489180eee09cc5b665d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Tue, 15 Feb 2022 20:40:57 +0300 Subject: [PATCH] RPC: Avoid calling write() so many times Using serializePart with conn.write as the write delegate avoid allocation but results in SO MANY write syscals that we spend almost all of our cpu time doing syscalls. --- source/agora/network/RPC.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/agora/network/RPC.d b/source/agora/network/RPC.d index 8f79b242dfa..a438854dc4a 100644 --- a/source/agora/network/RPC.d +++ b/source/agora/network/RPC.d @@ -267,10 +267,10 @@ public class RPCClient (API) : API // Send the method type conn.wlock.lock(); - serializePart(method, &conn.write); + conn.write(serializeFull(method)); // List of parameters foreach (ref p; params) - serializePart(p, &conn.write); + conn.write(serializeFull(p)); conn.flush(); conn.wlock.unlock(); @@ -640,7 +640,7 @@ private void handleThrow (API) (scope API api, RPCConnection stream, Duration ti { mixin("auto foo = ", CallMixin); log.trace("[SERVER] Returning {}", foo); - serializePart(foo, (in ubyte[] v) { stream.write(v); }); + stream.write(serializeFull(foo)); log.trace("[SERVER] Done writing..."); } return;