On Sat, Nov 06, 2021 at 06:23:27PM +0100, Martin Pieuchot wrote: > On 06/11/21(Sat) 15:53, Visa Hankala wrote: > > On Fri, Nov 05, 2021 at 10:04:50AM +0100, Martin Pieuchot wrote: > > > New poll/select(2) implementation convert 'struct pollfd' and 'fdset' to > > > knotes (kqueue event descriptors) then pass them to the kqueue subsystem. > > > A knote is allocated, with kqueue_register(), for every read, write and > > > except condition watched on a given FD. That means at most 3 allocations > > > might be necessary per FD. > > > > > > The diff below reduce the overhead of per-syscall allocation/free of those > > > descriptors by leaving those which didn't trigger on the kqueue across > > > syscall. Leaving knotes on the kqueue allows kqueue_register() to re-use > > > existing descriptor instead of re-allocating a new one. > > > > > > With this knotes are now lazily removed. The mechanism uses a serial > > > number which is incremented for every syscall that indicates if a knote > > > sitting in the kqueue is still valid or should be freed. > > > > > > Note that performance improvements might not be visible with this diff > > > alone because kqueue_register() still pre-allocate a descriptor then drop > > > it. > > > > > > visa@ already pointed out that the lazy removal logic could be integrated > > > in kqueue_scan() which would reduce the complexity of those two syscalls. > > > I'm arguing for doing this in a next step in-tree. > > > > I think it would make more sense to add the removal logic to the scan > > function first as doing so would keep the code modifications more > > logical and simpler. This would also avoid the need to go through > > a temporary removal approach. > > I totally support your effort and your design however I don't have the > time to do another round of test/debugging. So please, can you take > care of doing these cleanups afterward? If not, please send a full diff > and take over this feature, it's too much effort for me to work out of > tree.
I drop my diff for now. It has a bug at least in the handling of serial wraparounds.
