On Thu, Jul 07, 2022 at 10:04:23AM +0100, Stefan Hajnoczi wrote:
>
>Does this patch solve the issue? The idea is to defer
>poll_set_started(false) for as long as possible.
Good idea! It is straightforward.
>
>diff --git a/util/aio-posix.c b/util/aio-posix.c
>index 731f3826c0..536f8b2534 100644
>--- a/util/aio-posix.c
>+++ b/util/aio-posix.c
>@@ -591,12 +591,6 @@ static bool try_poll_mode(AioContext *ctx, AioHandlerList
>*ready_list,
> return true;
> }
> }
>-
>- if (poll_set_started(ctx, ready_list, false)) {
>- *timeout = 0;
>- return true;
>- }
>-
> return false;
> }
>
>@@ -657,6 +651,11 @@ bool aio_poll(AioContext *ctx, bool blocking)
> * system call---a single round of run_poll_handlers_once suffices.
> */
> if (timeout || ctx->fdmon_ops->need_wait(ctx)) {
>+ if (poll_set_started(ctx, &ready_list, false)) {
>+ timeout = 0;
>+ progress = true;
In this case, is it ok to skip the call of ->wait() below? If yes, maybe put
the call in the "else" path.
>+ }
>+
> ctx->fdmon_ops->wait(ctx, &ready_list, timeout);
> }
>
Anyway,
Reviewed-by: Chao Gao <[email protected]>
And my tests show your change works well. The number of notifications is
significantly reduced from ~80K/s to tens.
Tested-by: Chao Gao <[email protected]>