Skip to content

Commit

Permalink
RPC: Avoid calling write() so many times
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
omerfirmak committed Feb 15, 2022
1 parent 5315610 commit 74bed64
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/agora/network/RPC.d
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 74bed64

Please sign in to comment.