aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix/posix_pollq_kqueue.c
Commit message (Collapse)AuthorAge
* kqueue: support concurrent pollersGarrett D'Amore2024-12-30
| | | | | | | | | | | | | This allows greatly increased scalability for kqueue based systems with lots of cores (more likely FreeBSD than Darwin, as most macs only have a smattering of cores), but even for macs we can engage a few cores for system calls giving improvements. The implementation here is pretty simple -- each file descriptor gets assigned to its own kqueue by taking the numeric value of the file descriptor modulo the number of kqueues we have opened. The same approach will be adopted for epoll and Solaris/illumos port events.
* pollers: use atomic bit masking operations to eliminate lockssGarrett D'Amore2024-12-22
| | | | This is done for kqueue and poll. Others coming soon.
* posix pollers: inline the pfd and make callbacks constantGarrett D'Amore2024-12-20
| | | | | | | This change moves the posix pollers to inline the PFD and makes the callbacks constant, so that we can dispense with tests, failures, and locks. It is anticipated that this will reduce lock based pressure on the bus and increase performance modestly.
* posix pollers: expose pfd structures (for sizes) and fix poller selectionGarrett D'Amore2024-12-19
| | | | | | | | | | | | | The poller selection in the previous poller changes for select were not quite functional. Also, while testing poll() based poller, there were problems where it simply did not work correctly, so this addresses those, and it seems to work now. The pfd structures are exposed as we intend to allow inlining them to eliminate the separate allocation and potential for failure during initialization. We also want to have plans afoot to eliminate a lot of the extra locking done done on each I/O iteration, and this is setting the foundation for that.
* kqueue: eliminate extra locking on each I/OGarrett D'Amore2024-12-18
| | | | | This should reduce lock pressure during I/O for FreeBSD and macOS, and should provide a small performance benefit.
* POSIX poller: add support for select, and for choosing the pollerGarrett D'Amore2024-12-17
| | | | | Some platforms or configurations may not have more modern options like kqueue or epoll, or may be constrained by policy.
* refactor initialization/finalizationGarrett D'Amore2024-11-11
| | | | | | | | | Applications must now call nng_init(), but they can supply a set of parameters optionally. The code is now safe for multiple libraries to do this concurrently, meaning nng_fini no longer can race against another instance starting up. The nni_init checks on all public APIs are removed now.
* fixes #960 NNG threads inherit application thread nameGarrett D'Amore2020-08-08
| | | | | | This also exposes an nng_thread_set_name() function for applications to use. All NNG thread names start with "nng:". Note that support is highly dependent on the operating system.
* fixes #1275 Test timeouts on FreeBSDGarrett D'Amore2020-08-08
| | | | | | | | | | This was responsible for hangs in close on FreeBSD. Apparently our use of EVFILT_USER was incorrect, and rather than fix it, we have switched to using a notification pipe for synchronizing closing pipes. In addition to fixing this problem, it should significantly improve things for NetBSD and OpenBSD, which will now be able tbenefit from kqueue(), since we no longer depend on EVFILT_USER.
* fixes #1112 POSIX pollq finalizers could be simplerGarrett D'Amore2020-01-05
| | | | | | | | | | | We reap the connections when closing, to ensure that the clean up is done outside the pollq thread. This also reduces pressure on the pollq, we think. But more importantly it eliminates some complex code that was meant to avoid deadlocks, but ultimately created other use-after-free challenges. This work is an enabler for further simplifications in the aio/task logic. While here we converted some potentially racy locking of the dialers and reference counts to simpler lock-free reference counting.
* Various clang tidy fixups in the POSIX pollers.Garrett D'Amore2019-12-26
|
* fixes #687 POLLHUP is problematic on macOS too...Garrett D'Amore2018-08-30
| | | | | | | | | Basically, we can ignore EV_EOF, as we wind up still alerting the corresponding events. EV_ERROR we still treat as HUP. (The EV_EOF was responsible for prematurely closing the socket and aborting transactions while there was still data in the socket buffers.)
* fixes #575 kqueue spins hardGarrett D'Amore2018-07-04
| | | | | This sets the kqueue events to autoclear, reducing CPU usage to normal sane levels, and eliminating the hard spin.
* fixes #484 crashes in websocket transportGarrett D'Amore2018-05-29
| | | | | | | | | | | | | | | | | | | | | | | fixes #490 posix_epdesc use-after-free bug fixes #489 Sanitizer based testing would help fixes #492 Numerous memory leaks found with sanitizer This introduces support for compiler-based sanitizers when using clang or gcc (and not on Windows). See NNG_SANITIZER for possible settings such as "thread" or "address". Furthermore, we have fixed the issues we found with both the thread and address sanitizers. We believe that the thread issues pointed to a low frequency use-after-free responsible for rare crashes in some of the tests. The tests generally have their timeouts doubled when running under a sanitizer, to account for the extra long times that the sanitizer can cause these to take. While here, we also changed the compat_ws test to avoid a particularly painful and time consuming DNS lookup, and we made the nngcat_unlimited test a bit more robust by waiting before sending traffic.
* fixes #352 aio lock is burning hotGarrett D'Amore2018-05-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #326 consider nni_taskq_exec_synch() fixes #410 kqueue implementation could be smarter fixes #411 epoll_implementation could be smarter fixes #426 synchronous completion can lead to panic fixes #421 pipe close race condition/duplicate destroy This is a major refactoring of two significant parts of the code base, which are closely interrelated. First the aio and taskq framework have undergone a number of simplifications, and improvements. We have ditched a few parts of the internal API (for example tasks no longer support cancellation) that weren't terribly useful but added a lot of complexity, and we've made aio_schedule something that now checks for cancellation or other "premature" completions. The aio framework now uses the tasks more tightly, so that aio wait can devolve into just nni_task_wait(). We did have to add a "task_prep()" step to prevent race conditions. Second, the entire POSIX poller framework has been simplified, and made more robust, and more scalable. There were some fairly inherent race conditions around the shutdown/close code, where we *thought* we were synchronizing against the other thread, but weren't doing so adequately. With a cleaner design, we've been able to tighten up the implementation to remove these race conditions, while substantially reducing the chance for lock contention, thereby improving scalability. The illumos poller also got a performance boost by polling for multiple events. In highly "busy" systems, we expect to see vast reductions in lock contention, and therefore greater scalability, in addition to overall improved reliability. One area where we currently can do better is that there is still only a single poller thread run. Scaling this out is a task that has to be done differently for each poller, and carefuly to ensure that close conditions are safe on all pollers, and that no chance for deadlock/livelock waiting for pfd finalizers can occur.
* fixes #393 panic on illumos - epoll assertion errorGarrett D'Amore2018-05-06
| | | | | | | | This replaces the epoll support with proper illumos/SunOS port events. The port event support is structured so that it actually is superior to epoll and kqueue, because it avoids a single master lock on the poller. In the future we will explore this for macOS and Linux pollers.
* fixes #318 Assertion on macOS -- kevent() returns EINPROGRESS.Garrett D'Amore2018-03-30
|
* kqueue: add license infoLiam Staskawicz2018-03-04
|
* kqueue: add kqueue-based pollq implementationLiam Staskawicz2018-03-02