… | |
… | |
47 | * without any syscalls. what's not to like? |
47 | * without any syscalls. what's not to like? |
48 | * d) ok, it's vastly more complex, but that's ok, really. |
48 | * d) ok, it's vastly more complex, but that's ok, really. |
49 | * e) why 3 mmaps instead of one? one would be more space-efficient, |
49 | * e) why 3 mmaps instead of one? one would be more space-efficient, |
50 | * and I can't see what benefit three would have (other than being |
50 | * and I can't see what benefit three would have (other than being |
51 | * somehow resizable/relocatable, but that's apparently not possible). |
51 | * somehow resizable/relocatable, but that's apparently not possible). |
|
|
52 | * (FIXME: newer kernels can use 2 mmaps only, need to look into this). |
52 | * f) hmm, it's practiclaly undebuggable (gdb can't access the memory, and |
53 | * f) hmm, it's practiclaly undebuggable (gdb can't access the memory, and |
53 | the bizarre way structure offsets are commuinicated makes it hard to |
54 | * the bizarre way structure offsets are communicated makes it hard to |
54 | * just print the ring buffer heads, even *iff* the memory were visible |
55 | * just print the ring buffer heads, even *iff* the memory were visible |
55 | * in gdb. but then, that's also ok, really. |
56 | * in gdb. but then, that's also ok, really. |
56 | * g) well, you cannot specify a timeout when waiting for events. no, |
57 | * g) well, you cannot specify a timeout when waiting for events. no, |
57 | * seriously, the interface doesn't support a timeout. never seen _that_ |
58 | * seriously, the interface doesn't support a timeout. never seen _that_ |
58 | * before. sure, you can use a timerfd, but that's another syscall |
59 | * before. sure, you can use a timerfd, but that's another syscall |
59 | * you could have avoided. overall, this bizarre omission smells |
60 | * you could have avoided. overall, this bizarre omission smells |
60 | * like a µ-optimisation by the io_uring author for his personal |
61 | * like a µ-optimisation by the io_uring author for his personal |
61 | * applications, to the detriment of everybody else who just wants |
62 | * applications, to the detriment of everybody else who just wants |
62 | * an event loop. but, umm, ok, if that's all, it could be worse. |
63 | * an event loop. but, umm, ok, if that's all, it could be worse. |
|
|
64 | * (FIXME: jens mentioned timeout commands, need to investigate) |
63 | * h) there is a hardcoded limit of 4096 outstanding events. okay, |
65 | * h) there is a hardcoded limit of 4096 outstanding events. okay, |
64 | * at least there is no arbitrary low system-wide limit... |
66 | * at least there is no arbitrary low system-wide limit... |
|
|
67 | * (FIXME: apparently, this was increased to 32768 in later kernels( |
65 | * i) unlike linux aio, you *can* register more then the limit |
68 | * i) unlike linux aio, you *can* register more then the limit |
66 | * of fd events, and the kernel will "gracefully" signal an |
69 | * of fd events, and the kernel will "gracefully" signal an |
67 | * overflow, after which you could destroy and recreate the kernel |
70 | * overflow, after which you could destroy and recreate the kernel |
68 | * state, a bit bigger, or fall back to e.g. poll. thats not |
71 | * state, a bit bigger, or fall back to e.g. poll. thats not |
69 | * totally insane, but kind of questions the point a high |
72 | * totally insane, but kind of questions the point a high |
70 | * performance I/O framework when it doesn't really work |
73 | * performance I/O framework when it doesn't really work |
71 | * under stress. |
74 | * under stress. |
|
|
75 | * (FIXME: iouring should no longer drop events, need to investigate) |
72 | * j) but, oh my! is has exactly the same bugs as the linux aio backend, |
76 | * j) but, oh my! is has exactly the same bugs as the linux aio backend, |
73 | * where some undocumented poll combinations just fail. |
77 | * where some undocumented poll combinations just fail. |
74 | * so we need epoll AGAIN as a fallback. AGAIN! epoll!! and of course, |
78 | * so we need epoll AGAIN as a fallback. AGAIN! epoll!! and of course, |
75 | * this is completely undocumented, have I mantioned this already? |
79 | * this is completely undocumented, have I mantioned this already? |
76 | * k) overall, the *API* itself is, I dare to say, not a total trainwreck. |
80 | * k) overall, the *API* itself is, I dare to say, not a total trainwreck. |
… | |
… | |
576 | timeout = EV_TS_CONST (0.); |
580 | timeout = EV_TS_CONST (0.); |
577 | else |
581 | else |
578 | /* no events, so maybe wait for some */ |
582 | /* no events, so maybe wait for some */ |
579 | iouring_tfd_update (EV_A_ timeout); |
583 | iouring_tfd_update (EV_A_ timeout); |
580 | |
584 | |
581 | /* only enter the kernel if we have somethign to submit, or we need to wait */ |
585 | /* only enter the kernel if we have something to submit, or we need to wait */ |
582 | if (timeout || iouring_to_submit) |
586 | if (timeout || iouring_to_submit) |
583 | { |
587 | { |
584 | int res; |
588 | int res; |
585 | |
589 | |
586 | EV_RELEASE_CB; |
590 | EV_RELEASE_CB; |
… | |
… | |
606 | iouring_init (EV_P_ int flags) |
610 | iouring_init (EV_P_ int flags) |
607 | { |
611 | { |
608 | if (!epoll_init (EV_A_ 0)) |
612 | if (!epoll_init (EV_A_ 0)) |
609 | return 0; |
613 | return 0; |
610 | |
614 | |
|
|
615 | iouring_entries = IOURING_INIT_ENTRIES; |
|
|
616 | iouring_max_entries = 0; |
|
|
617 | |
|
|
618 | if (iouring_internal_init (EV_A) < 0) |
|
|
619 | { |
|
|
620 | iouring_internal_destroy (EV_A); |
|
|
621 | return 0; |
|
|
622 | } |
|
|
623 | |
611 | ev_io_init (&iouring_epoll_w, iouring_epoll_cb, backend_fd, EV_READ); |
624 | ev_io_init (&iouring_epoll_w, iouring_epoll_cb, backend_fd, EV_READ); |
612 | ev_set_priority (&iouring_epoll_w, EV_MAXPRI); |
625 | ev_set_priority (&iouring_epoll_w, EV_MAXPRI); |
613 | |
626 | |
614 | ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ); |
627 | ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ); |
615 | ev_set_priority (&iouring_tfd_w, EV_MAXPRI); |
628 | ev_set_priority (&iouring_tfd_w, EV_MAXPRI); |
616 | |
|
|
617 | iouring_entries = IOURING_INIT_ENTRIES; |
|
|
618 | iouring_max_entries = 0; |
|
|
619 | |
|
|
620 | if (iouring_internal_init (EV_A) < 0) |
|
|
621 | { |
|
|
622 | iouring_internal_destroy (EV_A); |
|
|
623 | return 0; |
|
|
624 | } |
|
|
625 | |
629 | |
626 | ev_io_start (EV_A_ &iouring_epoll_w); |
630 | ev_io_start (EV_A_ &iouring_epoll_w); |
627 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
631 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
628 | |
632 | |
629 | ev_io_start (EV_A_ &iouring_tfd_w); |
633 | ev_io_start (EV_A_ &iouring_tfd_w); |