Slow XQueryPointer?

Adam Jackson ajax at redhat.com
Thu Jan 26 06:37:28 PST 2012


On Thu, 2012-01-26 at 15:22 +0200, Lauri Kasanen wrote:
> Hi list
> 
> Tracing why there's the occasional delay in Irrlicht apps showed the
> culprit as XQueryPointer.
> 
> It's called once per frame, but occasionally it takes much longer than
> the average 80us - up to 30ms. This is a huge delay and easily
> noticable as a skip/jitter.
> 
> Trying various alternatives, like using the mouse position from the
> last Motion/Click event proved jerky/jittery and seemed to lag the
> mouse by some frames.
> 
> Any suggestions on making the call faster? Would it be possible to use
> it with a timeout, say, if it takes over 1ms, abort?

Xlib doesn't work that way.  You could do that with XCB and a main loop
though.

I'd suspect one of two scenarios.  Either the X server has some periodic
work it's doing, or the kernel's not waking up X promptly enough.  Both
should be fairly easy to work through.  In the former case, it's most
likely to be something on the WakeupHandler or BlockHandler call chains
in the X server, which run on either side of the call to select() in the
main loop.

Probably the easiest way to see what's going on is to have your app
print timestamps when it calls QueryPointer, and 'strace -t -e file' on
the X server (from an ssh session into the machine under test).  Then
compare.  If there's a long lag between your call to QueryPointer to the
X server waking up from select and handling it, then the kernel's not
getting the message across in time.  If there's a lag between the server
waking up and writing back the response, then the server's doing excess
work.

If it's a server issue we'd need to know what driver and hardware you're
using.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20120126/0b8181da/attachment.pgp>


More information about the xorg mailing list