From ab85494f8bf0b96c1129a81059da9b428942a1ed Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sat, 25 Sep 2021 14:38:10 -0600 Subject: [PATCH] t/io_uring: batch stat updates Track the last clock_index, and batch increments if at all possible. Signed-off-by: Jens Axboe --- t/io_uring.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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); -- 2.25.1