ev_run() pipe_write_wanted improvement idea
Olivier Langlois
olivier at trillion01.com
Wed Jul 31 14:10:42 CEST 2024
Hi,
this is the first time that it happens to me that I have a possible way
to improve libev. I thought that it was impossible but I think that I
got a good idea!
In ev_run(), there is this code:
/* from now on, we want a pipe-wake-up */
pipe_write_wanted = 1;
ECB_MEMORY_FENCE; /* make sure pipe_write_wanted is visible
before we check for potential skips */
if (ecb_expect_true (!(flags & EVRUN_NOWAIT || idleall ||
!activecnt || pipe_write_skipped)))
I think that it could be changed to:
/* from now on, we want a pipe-wake-up */
pipe_write_wanted = !(flags & EVRUN_NOWAIT || idleall ||
!activecnt || pipe_write_skipped);
ECB_MEMORY_FENCE; /* make sure pipe_write_wanted is visible
before we check for potential skips */
// retest pipe_write_skipped
if (ecb_expect_true (pipe_write_wanted && !pipe_write_skipped))
in that way, if the backend_poll is going to be invoked without
blocking, the loop will not request to receive async notifications
through the eventfd.
Greetings,
More information about the libev
mailing list