about summary refs log tree commit homepage
path: root/lib/PublicInbox/DSKQXS.pm
DateCommit message (Collapse)
2024-04-03treewide: avoid getpid for more ownership checks
There are still some places where on_destroy isn't suitable, This gets rid of getpid() calls in most of those cases to reduce syscall costs and cleanup syscall trace output.
2023-11-01ds: move maxevents further down the stack
The epoll implementation is the only one which respects the limit (kevent would, but IO::KQueue does not). In any case, I'm not a fan of the maxevents=1000 historical default since it leads to fairness problems with shared non-blocking listeners across multiple daemon workers.
2023-09-11ds: use object-oriented API for epoll
This allows us to cut down on imports and reduce code. This also makes it easier (in the next commit) to provide an option to disable epoll/kqueue when saving an FD is valued over scalability.
2023-09-11daemon: depend on DS event_loop in master process, too
The awaitpid API turns out to be quite handy for managing long-lived worker processes. This allows us to ensure all our uses of signalfd (and kevent emulation) are non-blocking.
2023-09-06dskqxs: get rid of needless confess check
Destruction order is unpredictable at process teardown, so confessing or warning here is unnecessary, just break out of the sub since it's for to delete an entry, anyways.
2022-11-28switch inotify/kevent stuff to v5.12
Another tiny step towards an eventual startup time improvements by avoiding strict.pm
2022-11-28dskqxs:carp
2022-10-11dskqxs: fix loop to allow `next'
`do {} while(...)' loops in Perl don't support `next', actually :x This only affects *BSD platforms with IO::KQueue installed. Fixes: d6674af04cb74a4e "httpd|nntpd: avoid missed signal wakeups"
2021-10-01ds: simplify signalfd use
Since signalfd is often combined with our event loop, give it a convenient API and reduce the code duplication required to use it. EventLoop is replaced with ::event_loop to allow consistent parameter passing and avoid needlessly passing the package name on stack. We also avoid exporting SFD_NONBLOCK since it's the only flag we support. There's no sense in having the memory overhead of a constant function when it's in cold code.
2021-01-01update copyrights for 2021
Using "make update-copyrights" after setting GNULIB_PATH in my config.mak
2021-01-01syscall: SFD_NONBLOCK can be a constant, again
Since Perl exposes O_NONBLOCK as a constant, we can safely make SFD_NONBLOCK a constant, too. This is not the case for SFD_CLOEXEC, since O_CLOEXEC is not exposed by Perl despite being used internally in the interpreter.
2020-12-28ds: flatten + reuse @events, epoll_wait style fixes
Consistently returning the equivalent of pollfd.revents in a portable manner was never worth the effort for us, as we use the same ->event_step callback regardless of POLLIN/POLLOUT/POLLHUP. Being a Perl, @events knows it size and we don't have to return a maximum index for the caller to iterate on. We can also avoid redundant integer coercion ("+0") since we ensure everything is an IV in other places. Finally, vec() is preferable to ("\0" x $size) for resizing buffers because it only needs to write the extended portion and not overwrite the entire buffer.
2020-08-07syscall: support sparc64 (and maybe other big-endian systems)
Thanks to the GCC compile farm project, we can wire up syscalls for sparc64 and set system-specific SFD_* constants properly. I've FINALLY figured out how to use POSIX::SigSet to generate a usable buffer for the syscall perlfunc. This is required for endian-neutral behavior and relevant to sparc64, at least. There's no need for signalfd-related stuff to be constants, either. signalfd initialization is never a hot path and a stub subroutine for constants uses several KB of memory in the interpreter. We'll drop the needless SEEK_CUR import while we're importing O_NONBLOCK, too.
2020-04-15dskqxs: ignore EV_SET errors on EVFILT_WRITE
Just like the EPOLL_CTL_ADD emulation path, the EPOLL_CTL_MOD and EPOLL_CTL_DEL emulation paths can fail if attempting to install an EVFILT_WRITE for a read-only pipe. I've only observed this on the EPOLL_CTL_DEL emulation path, but I suspect it could happen on the EPOLL_CTL_MOD path as well. Increasing the amount of read-only pipes we rely on with altid exports via sqlite3 made this old bug more apparent and reproducible while looping the test suite. This may be adjusted in the future to deal with write-only pipes, but we currently don't have any of those watched by kqueue.
2020-02-08doc: mark some TODO items as done
NNTP TLS and COMPRESS support and cgit spawning from the WWW interface were implemented last year. Given the lack of syscall number stability guarantee on the OpenBSD and FreeBSD, I don't think supporting a pure-Perl kevent is feasible. Inline::C may still be an option since IO::KQueue is abandoned, though, as it is for some Linux-only syscalls and maybe some POSIX ones not covered by POSIX.pm.
2020-02-06treewide: run update-copyrights from gnulib for 2019
I didn't wait until September to do it, this year!
2019-11-27httpd|nntpd: avoid missed signal wakeups
Our attempt at using a self-pipe in signal handlers was ineffective, since pure Perl code execution is deferred and Perl doesn't use an internal self-pipe/eventfd. In retrospect, I actually prefer the simplicity of Perl in this regard... We can use sigprocmask() from Perl, so we can introduce signalfd(2) and EVFILT_SIGNAL support on Linux and *BSD-based systems, respectively. These OS primitives allow us to avoid a race where Perl checks for signals right before epoll_wait() or kevent() puts the process to sleep. The (few) systems nowadays without signalfd(2) or IO::KQueue will now see wakeups every second to avoid missed signals.
2019-11-27dskqxs: fix missing EV_DISPATCH define
Oops, IO::KQueue support was broken due to this missing constant. Add a new ds-kqxs.t test case to ensure we test the IO::KQueue path if IO::KQueue is available.
2019-06-29dskqxs: more closely match epoll semantics
EV_DISPATCH is actually a better match for EPOLLONESHOT semantics than EV_ONESHOT in that it doesn't require EV_ADD for every mod operation. Blindly using EV_ADD everywhere forces the FreeBSD kernel to do extra allocations up front, so it's best avoided.
2019-06-29listener: use edge-triggered notifications
We don't need extra wakeups from the kernel when we know a listener is already active.
2019-06-26ds: cleanup poll test and avoid clobbering imports
On Linux systems with epoll support, we don't want to be clobbering defined subs in the t/ds-poll.t test; so use OO ->method dispatch instead and require users to explicitly import subs via EXPORT_OK.
2019-06-24ds: split out IO::KQueue-specific code
We don't need to code multiple event loops or have branches in watch() if we can easily make the IO::KQueue-based interface look like our lower-level epoll_* API.