summaryrefslogtreecommitdiff
path: root/src/Server.zig
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2026-01-10 16:08:23 -0500
committerRobby Zambito <contact@robbyzambito.me>2026-01-10 16:42:43 -0500
commit0861703ddce8c46b732cfb773aabe9daa9c5da48 (patch)
tree7b40b541547da898546a1f2e62f86dadf1dd441e /src/Server.zig
parent99ea7556581a678684e30202a8eee654a001588a (diff)
Sleep to go faster
The problem was I was basically flushing twice for every message when doing request reply. This gives the sender the opportunity to finish writing a full message to the queue, which we then check for before flushing. This makes request reply latency benchmarks go down from like 90ms to 200us.
Diffstat (limited to 'src/Server.zig')
-rw-r--r--src/Server.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Server.zig b/src/Server.zig
index e20f5c0..49f54e2 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -47,6 +47,7 @@ const Subscription = struct {
// would put an invalid set series of bytes in the receivers queue.
_ = try self.queue.putUncancelable(io, chunk, chunk.len);
}
+ try io.checkCancel();
}
};
@@ -382,7 +383,10 @@ fn publishMessage(
) catch unreachable;
msg_chunks.appendBounded(msg.payload) catch unreachable;
- try subscription.send(io, msg_chunks.items[0..chunk_count]);
+ subscription.send(io, msg_chunks.items[0..chunk_count]) catch |err| switch (err) {
+ error.Closed => {},
+ error.Canceled => |e| return e,
+ };
}
}