From 724f44c31bb79d75bb6d6a49463ea79c11691297 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Tue, 5 May 2015 13:57:10 +0200 Subject: [PATCH] socket: change the order of POLLIN and POLLOUT in iscsi_service the original idea of writing to the socket before reading was to put data on the wire as early as possible and avoid potential latency increase due to long taking callbacks invoked in iscsi_read_from_socket. Benchmarking with libiscsi userland tools have shown that changing the order increases throughput by about 5%. The reason is that during POLLIN we might receive an updated MaxCmdSN which might us allow to send new data out during POLLOUT. For Qemu the change doesn't matter since POLLIN and POLLOUT are processed independently. Signed-off-by: Peter Lieven --- lib/socket.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index 15095e3..da89c5a 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -879,17 +879,16 @@ iscsi_service(struct iscsi_context *iscsi, int revents) return 0; } - if (revents & POLLOUT && (iscsi->outqueue != NULL || iscsi->outqueue_current != NULL)) { - if (iscsi_write_to_socket(iscsi) != 0) { - return iscsi_service_reconnect_if_loggedin(iscsi); - } - } if (revents & POLLIN) { if (iscsi_read_from_socket(iscsi) != 0) { return iscsi_service_reconnect_if_loggedin(iscsi); } } - + if (revents & POLLOUT) { + if (iscsi_write_to_socket(iscsi) != 0) { + return iscsi_service_reconnect_if_loggedin(iscsi); + } + } return 0; }