Don't always read more events
libevdev_next_event()
calls read_more_events()
in all cases but blocking reads. This comes from a time when we had to battle with frequent SYN_DROPPED
, especially on synaptics touchpads. I haven't seen many SYN_DROPPED
recently and in most of those cases calling the extra read()
wouldn't have helped because the machine was stalled for longer than the interval.
Furthermore, the most well-known users of libevdev all assemble the state before doing any heavy lifting, so any stalls would likely happen after SYN_REPORT
but not within a frame.
Right now, on an average touchpad with a few axes and assuming there's no event waiting right now, we end up calling read()
somewhere around 10 times per event frame (ABS_X
, ABS_Y
, a few ABS_MT
, and maybe a BTN_
event). That's not efficient...
So our two options here are:
- only try to read extra events after a
SYN_REPORT
- don't read extra events unless explicitly called for, i.e. when there are no events in the queue on
libevdev_next_event()
.
The former would have little visible behaviour change, the latter could potentially trigger bugs in client stacks but has the side effect of having a more predictable performance profile. Plus it's easier to implement.