[Xcb] Reply Buffering Question

Jamey Sharp jamey at minilop.net
Sat Nov 17 12:29:57 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/16/07, Eamon Walsh <ewalsh at tycho.nsa.gov> wrote:
>   iterator = xcb_input_list_input_devices_devices_iterator(reply);
>   while (iterator.rem) {
>
>     cookie = xcb_foo_request(conn);
>
>     error = xcb_request_check(conn, cookie);
>     if (error)
>        ...
>
>     xcb_input_deviceinfo_next(&iterator);
>   }

Bart answered your question, but I'd like to comment on this pattern.
As coded here, every call to xcb_request_check is going to issue a
GetInputFocus sync request and block waiting for the reply.

This loop will go quite a bit faster (lower total latency, lower
bandwidth, fewer context switches, ...) if you can split it--run all the
xcb_foo_request calls first, and then all the xcb_request_check calls.
Then only the first xcb_request_check will sync, and the rest will run
without doing any I/O.

You can do even better if you have some other request you need to make
anyway that will have a reply. Issue that request and wait for its reply
after you're done issuing xcb_foo_requests; then make the calls to
xcb_request_check. That way no sync requests should be issued, so you'll
only make requests you actually wanted.

Jamey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHP085p1aplQ4I9mURAnARAJ9Z4kdO+Mat+BBKHOJRHOyBnl+DhgCdGfip
tobJLoeXD3IyW8X8qAT3O3w=
=97iG
-----END PGP SIGNATURE-----


More information about the Xcb mailing list