thank you for your reply.
I have the same opinion about Linux aio and io_uring. The performance of aio is
not as good and problematic as described, but the use of io_uring may be
limited by the version of the Linux kernel and it makes me hesitant.
There may be very few people who follow up on Linux 4.x / 5.x aggressively,
that is to say, there will be very few people who actually use it! And I also
have to maintain the old 2.6.32 kernel project).
...
The following code is my implementation of the IO watcher wrapper. The only
difference is: "the IO watcher passed to the core IO init method may have
called the core IO stop multiple times (object reuse). Such behavior is to
reduce the frequent creation or destruction of IO watcher."
#define CORE_LOOP core_default_loop()
/* =========== Timer =========== */
void
core_timer_init(core_timer *timer, _TIMER_CB cb){
timer->repeat = timer->at = 0x0;
ev_init(timer, cb);
}
void
core_timer_start(core_loop *loop, core_timer *timer, ev_tstamp timeout){
timer->repeat = timeout;
ev_timer_again(loop ? loop : CORE_LOOP, timer);
}
void
core_timer_stop(core_loop *loop, core_timer *timer){
timer->repeat = timer->at = 0x0;
ev_timer_again(loop ? loop : CORE_LOOP, timer);
}
/* =========== Timer =========== */
/* =========== IO =========== */
void
core_io_init(core_io *io, _IO_CB cb, int fd, int events){
ev_io_init(io, cb, fd, events);
}
void
core_io_start(core_loop *loop, core_io *io){
ev_io_start(loop ? loop : CORE_LOOP, io);
}
void
core_io_stop(core_loop *loop, core_io *io){
if (io->events || io->fd){
ev_io_stop(loop ? loop : CORE_LOOP, io);
io->fd = io->events = 0x0;
}
}
/* =========== IO =========== */
Even though I don't think they will adversely affect what you said, for
security reasons I will put the code up to discuss with you and ask if there is
an optimization solution.
It is worth mentioning the use of the ev_timer_again method: "The consequence
of modifying timer-> repeat is that it will cause the min-heap to be
adjusted every time. Will frequent use have a certain impact or even worse
performance?", Because The implementation of ev_timer_again is this (v4.25):
noinline void ev_timer_again (EV_P_ ev_timer *w)
EV_NOEXCEPT
{
EV_FREQUENT_CHECK;
clear_pending (EV_A_ (W)w);
if (ev_is_active (w))
{
if (w->repeat)
{
ev_at (w) = mn_now + w->repeat;
ANHE_at_cache (timers [ev_active (w)]);
adjustheap (timers, timercnt, ev_active (w));
}
else
ev_timer_stop (EV_A_ w);
}
else if (w->repeat)
{
ev_at (w) = w->repeat;
ev_timer_start (EV_A_ w);
}
EV_FREQUENT_CHECK;
}
The core_timer_* is packaged so that it is suitable for one-time / cyclic
"timer", and it does not need to apply for and release memory again and reuse
it until the program ends(Like core_io_*).
Recently, I was watching the code of libeio. When will libeio be ready to
release the official version?_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/libev