From: Jens Axboe Date: Sat, 25 Sep 2021 20:38:10 +0000 (-0600) Subject: t/io_uring: batch stat updates X-Git-Tag: fio-3.29~93 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=ab85494f8bf0;p=fio.git t/io_uring: batch stat updates Track the last clock_index, and batch increments if at all possible. Signed-off-by: Jens Axboe --- diff --git a/t/io_uring.c b/t/io_uring.c index 903e7cf8..503e5b69 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -484,6 +484,7 @@ static int reap_events(struct submitter *s) struct io_cq_ring *ring = &s->cq_ring; struct io_uring_cqe *cqe; unsigned head, reaped = 0; + int last_idx = -1, stat_nr = 0; head = *ring->head; do { @@ -508,12 +509,23 @@ static int reap_events(struct submitter *s) if (stats) { int clock_index = cqe->user_data >> 32; + if (last_idx != clock_index) { + if (last_idx != -1) { + add_stat(s, last_idx, stat_nr); + stat_nr = 0; + } + last_idx = clock_index; + } + stat_nr++; add_stat(s, clock_index, 1); } reaped++; head++; } while (1); + if (stat_nr) + add_stat(s, last_idx, stat_nr); + if (reaped) { s->inflight -= reaped; atomic_store_release(ring->head, head);