… | |
… | |
575 | C<EVBACKEND_POLL>. |
575 | C<EVBACKEND_POLL>. |
576 | |
576 | |
577 | =item C<EVBACKEND_LINUXAIO> (value 64, Linux) |
577 | =item C<EVBACKEND_LINUXAIO> (value 64, Linux) |
578 | |
578 | |
579 | Use the linux-specific linux aio (I<not> C<< aio(7) >> but C<< |
579 | Use the linux-specific linux aio (I<not> C<< aio(7) >> but C<< |
580 | io_submit(2) >>) event interface available in post-4.18 kernels. |
580 | io_submit(2) >>) event interface available in post-4.18 kernels (but libev |
|
|
581 | only tries to use it in 4.19+). |
|
|
582 | |
|
|
583 | This is another linux trainwreck of an event interface. |
581 | |
584 | |
582 | If this backend works for you (as of this writing, it was very |
585 | If this backend works for you (as of this writing, it was very |
583 | experimental), it is the best event interface available on linux and might |
586 | experimental), it is the best event interface available on linux and might |
584 | be well worth enabling it - if it isn't available in your kernel this will |
587 | be well worth enabling it - if it isn't available in your kernel this will |
585 | be detected and this backend will be skipped. |
588 | be detected and this backend will be skipped. |
… | |
… | |
587 | This backend can batch oneshot requests and supports a user-space ring |
590 | This backend can batch oneshot requests and supports a user-space ring |
588 | buffer to receive events. It also doesn't suffer from most of the design |
591 | buffer to receive events. It also doesn't suffer from most of the design |
589 | problems of epoll (such as not being able to remove event sources from |
592 | problems of epoll (such as not being able to remove event sources from |
590 | the epoll set), and generally sounds too good to be true. Because, this |
593 | the epoll set), and generally sounds too good to be true. Because, this |
591 | being the linux kernel, of course it suffers from a whole new set of |
594 | being the linux kernel, of course it suffers from a whole new set of |
592 | limitations. |
595 | limitations, forcing you to fall back to epoll, inheriting all its design |
|
|
596 | issues. |
593 | |
597 | |
594 | For one, it is not easily embeddable (but probably could be done using |
598 | For one, it is not easily embeddable (but probably could be done using |
595 | an event fd at some extra overhead). It also is subject to a system wide |
599 | an event fd at some extra overhead). It also is subject to a system wide |
596 | limit that can be configured in F</proc/sys/fs/aio-max-nr> - each loop |
600 | limit that can be configured in F</proc/sys/fs/aio-max-nr>. If no aio |
597 | currently requires C<61> of this number. If no aio requests are left, this |
|
|
598 | backend will be skipped during initialisation. |
601 | requests are left, this backend will be skipped during initialisation, and |
|
|
602 | will switch to epoll when the loop is active. |
599 | |
603 | |
600 | Most problematic in practise, however, is that not all file descriptors |
604 | Most problematic in practice, however, is that not all file descriptors |
601 | work with it. For example, in linux 5.1, tcp sockets, pipes, event fds, |
605 | work with it. For example, in linux 5.1, tcp sockets, pipes, event fds, |
602 | files, F</dev/null> and a few others are supported, but ttys do not work |
606 | files, F</dev/null> and a few others are supported, but ttys do not work |
603 | (probably because of a bug), so this is not (yet?) a generic event polling |
607 | properly (a known bug that the kernel developers don't care about, see |
604 | interface. |
608 | L<https://lore.kernel.org/patchwork/patch/1047453/>), so this is not |
|
|
609 | (yet?) a generic event polling interface. |
605 | |
610 | |
|
|
611 | Overall, it seems the linux developers just don't want it to have a |
|
|
612 | generic event handling mechanism other than C<select> or C<poll>. |
|
|
613 | |
606 | To work around this latter problem, the current version of libev uses |
614 | To work around all these problem, the current version of libev uses its |
607 | epoll as a fallback for file deescriptor types that do not work. Epoll |
615 | epoll backend as a fallback for file descriptor types that do not work. Or |
608 | is used in, kind of, slow mode that hopefully avoids most of its design |
616 | falls back completely to epoll if the kernel acts up. |
609 | problems and requires 1-3 extra syscalls per active fd every iteration. |
|
|
610 | |
617 | |
611 | This backend maps C<EV_READ> and C<EV_WRITE> in the same way as |
618 | This backend maps C<EV_READ> and C<EV_WRITE> in the same way as |
612 | C<EVBACKEND_POLL>. |
619 | C<EVBACKEND_POLL>. |
613 | |
620 | |
614 | =item C<EVBACKEND_KQUEUE> (value 8, most BSD clones) |
621 | =item C<EVBACKEND_KQUEUE> (value 8, most BSD clones) |
615 | |
622 | |
616 | Kqueue deserves special mention, as at the time of this writing, it |
623 | Kqueue deserves special mention, as at the time this backend was |
617 | was broken on all BSDs except NetBSD (usually it doesn't work reliably |
624 | implemented, it was broken on all BSDs except NetBSD (usually it doesn't |
618 | with anything but sockets and pipes, except on Darwin, where of course |
625 | work reliably with anything but sockets and pipes, except on Darwin, |
619 | it's completely useless). Unlike epoll, however, whose brokenness |
626 | where of course it's completely useless). Unlike epoll, however, whose |
620 | is by design, these kqueue bugs can (and eventually will) be fixed |
627 | brokenness is by design, these kqueue bugs can be (and mostly have been) |
621 | without API changes to existing programs. For this reason it's not being |
628 | fixed without API changes to existing programs. For this reason it's not |
622 | "auto-detected" unless you explicitly specify it in the flags (i.e. using |
629 | being "auto-detected" on all platforms unless you explicitly specify it |
623 | C<EVBACKEND_KQUEUE>) or libev was compiled on a known-to-be-good (-enough) |
630 | in the flags (i.e. using C<EVBACKEND_KQUEUE>) or libev was compiled on a |
624 | system like NetBSD. |
631 | known-to-be-good (-enough) system like NetBSD. |
625 | |
632 | |
626 | You still can embed kqueue into a normal poll or select backend and use it |
633 | You still can embed kqueue into a normal poll or select backend and use it |
627 | only for sockets (after having made sure that sockets work with kqueue on |
634 | only for sockets (after having made sure that sockets work with kqueue on |
628 | the target platform). See C<ev_embed> watchers for more info. |
635 | the target platform). See C<ev_embed> watchers for more info. |
629 | |
636 | |