mastodon.green is one of the many independent Mastodon servers you can use to participate in the fediverse.
Plant trees while you use Mastodon. A server originally for people in the EU, but now open for anyone in the world

Administered by:

Server stats:

1.2K
active users

#select

2 posts2 participants0 posts today

First change since #swad 0.2 will actually be a (huge?) improvement to my #poser lib. So far, it was hardwired to use the good old #POSIX #select call. This is perfectly fine for handling around up to 100 (or at least less than 1000, YMMV) clients.

Some #select implementations offer defining the upper limit for checked file descriptors. Added support for that.

POSIX also specifies #poll, which has very similar #scalability issues, but slightly different. Added support for this as well.

And then, I went on to add support for the #Linux-specific #epoll and #BSD-specific #kqueue (#FreeBSD, #NetBSD, #OpenBSD, ...) which are both designed to *solve* any scalability issues 🥳

A little thing that slightly annoyed me about kqueue was that there's no support for temporarily changing the signal mask, so I had to do the silly dance shown in the screenshot. OTOH, it offers changing event filters and getting events in a single call, which I might try to even further optimize ... 😎

Replied in thread

@toomanysecrets It's kind of funny the talk is all about #epoll although the text then correctly tells that BSD's (originally #FreeBSD but adopted by the others as well) #kqueue was the first async event interface without the scalability issues of #select and #poll. 🙈

Talking of these, I'd say the "Before epoll" paragraph is, at least partially, wrong. It just omits select/poll. Both are specified in #POSIX (and therefore available on *many* systems), and both offer the same async model, with the drawback of having scalability limitations. As a rule of thumb, they're fine for a few hundred concurrent clients, but not more.

The really wasteful "forking model" (which is kind of classic Unix, really forking one process per client) predates both.

It's really a shame there is no common standard for the modern, really scalable APIs. 😞 We have #epoll, #kqueue, there's "IO completion ports" in Windows, etc. I tend to still use classic #select a lot, if more than a few hundred concurrent (!) clients is nothing you could ever expect for your software, it's still fine.