Following up to cf1a3045, if we know that we have more requests to
transmit (because the user was queueing up requests while we were busy
elsewhere), and our current request is short (a non-write, or a write
with a small payload), then our current command can be batched with
the next command.
The numbers here were not as dramatic and may be merely in the noise;
over three runs of:
$ time ~/nbdkit/nbdkit memory 100M --run 'examples/threaded-reads-and-writes
localhost 10809'
my machine improved runtime from 12.68s to 12.59s.
---
generator/states-issue-command.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/generator/states-issue-command.c b/generator/states-issue-command.c
index cce43d7..5d2a7e6 100644
--- a/generator/states-issue-command.c
+++ b/generator/states-issue-command.c
@@ -42,7 +42,7 @@
h->request.count = htobe32 ((uint32_t) cmd->count);
h->wbuf = &h->request;
h->wlen = sizeof (h->request);
- if (cmd->type == NBD_CMD_WRITE)
+ if (cmd->type == NBD_CMD_WRITE || cmd->next)
h->wflags = MSG_MORE;
SET_NEXT_STATE (%SEND_REQUEST);
return 0;
@@ -70,6 +70,8 @@
if (cmd->type == NBD_CMD_WRITE) {
h->wbuf = cmd->data;
h->wlen = cmd->count;
+ if (cmd->next && cmd->count < 64 * 1024)
+ h->wflags = MSG_MORE;
SET_NEXT_STATE (%SEND_WRITE_PAYLOAD);
}
else
--
2.20.1