4 ms·
The consumer (background thread) only polls; there is no need to wake up the consumer. At steady state, the consume is either blocked on I/O or is scanning the
by sriram_malhar 2y ago
The consumer (background thread) only polls; there is no need to wake up the consumer.
At steady state, the consume is either blocked on I/O or is scanning the producer buffers. When all producer buffers are empty, it can just sleep for a short time.
- geertj 2y agoThis would work in this specific case where we know that there is a maximum rate at which work is produced. Arguably I was hijacking the thread to discuss a more general problem that I've been thinking about for a while. I have the sense that a ring-buffer that has a wait-free push with low bound on consumer side latency that doesn't require fixed interval polling would be a nice primitive that I certainly could have used at times. And in fact ... the wait-free wakeup part of this is already there. Now that io_uring has futex support, a producer can enable kernel-side busy polling on the uring, and then submit a FUTEX_WAKE to the ring without doing any sys calls. This Github issue [1] has a nice description. [1] https://github.com/axboe/liburing/issues/385 https://github.com/axboe/liburing/issues/385
- gpderetta 2y agoI'm waiting for this to become mainstream: https://lwn.net/Articles/869140/ https://lwn.net/Articles/869140/ It could enable a full user space uring without the need of kernel side polling.
- geertj 2y agoInteresting, thanks for sharing. I did some digging on the linux-kernel mailing list and it seems that after the first patch series in Dec ‘21 and the LPC talk there was no further work on this. Too bad if true. Also I wasn’t able to easily find which hardware supports this today. I did see a reference to a RISC-V project that is adding a similar feature.