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 <pl@kamp.de>
This commit is contained in:
Peter Lieven
2015-05-05 13:57:10 +02:00
parent e9d67540e1
commit 724f44c31b

View File

@@ -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;
}