tech-x11 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kqueue: SIGIO?
On Wed, Sep 30, 2015 at 12:30:36AM +0200, Joerg Sonnenberger wrote:
> On Tue, Sep 29, 2015 at 10:09:51PM +0200, Rhialto wrote:
> > On Tue 29 Sep 2015 at 13:22:08 +0200, Tobias Nygren wrote:
> > > Here is the relevant bit of the talk if you are curious:
> > >
> > > https://www.youtube.com/watch?v=t400SmZlnO8&feature=youtu.be&t=1888
> >
> > So he wants a signal when a message is available in a kqueue, in other
> > words, can be read with kevent(2).
>
> Why oh why. I thought the X server finally got rid of the
> overcomplicated signal handlers. If there is any kind of load going on,
> the signal sending is more costly than occassional querying the kqueue
> for (other active) entries. If there is no load, it doesn't make a
> difference.
What he said. I've owned some fairly performance-critical single threaded
event driven code in my time, and it is my opinion that trying to use
signals to achieve client fairness is almost always a huge mistake.
The trick is almost always to structure the event loop so that checking
for work from another client is nearly zero-cost, and scales much less
than linearly with the number of clients. Given the very high cost of
handling a signal, it is pretty darned hard to do worse.
The way to get yourself in trouble is to chase false "optimizations"
involving processing-to-completion of too much work from a single client
at once, or shortcuts involving handing off data directly from one
client to another. The latter, at least, are really classic priority
inversion bugs in disguise.
In practice, the X server has a shared memory transport to most clients
and a shared memory interface to the display hardware; it should seldom
have syscalls to do. Arranging for nearly zero-cost "look aside" at
some other *properly designed and structured* shared memory source of
client requests should be pretty easy. Does the problem actually have
to do with the mouse and keyboard? Mouse's idea of having the kernel
write a flag word instead of interrupting the process seems like a
very nice fit if so.
--
Thor Lancelot Simon tls%panix.com@localhost
"We cannot usually in social life pursue a single value or a single moral
aim, untroubled by the need to compromise with others." - H.L.A. Hart
Home |
Main Index |
Thread Index |
Old Index