[Xcb] XPutImage and context switches / roundtrips?

Barton C Massey bart at cs.pdx.edu
Wed Sep 10 14:35:08 PDT 2008


In message <48C835AE.2050605 at hummingbird.com> you wrote:
> Clemens Eisserer wrote:
> > Is there anything that can be done against this?
> > Maybe increasing the buffer to something like 32kB, I guess this size
> > would be perfect for my use-case - but I have read somewhere that the
> > size is fixed to 4kb and can not be chaged at run-time, not even at
> > compile-time (which would be useless for me anyway).
> 
> It's the size of the OS's socket buffer that matters, not
> the size of XCB's internal buffer, really.
> 
> man setsockopt (look for SO_SNDBUF) might help. See also
> xcb_get_file_descriptor.
> 
> My Linux 2.6.26 box defaults to a reasonably large
> size. Maybe your OS is different.

You'll still do a switch into kernel context every time
XCB's buffer fills up and is written to the OS, and you'll
probably be scheduled over to the X server context at this
point.  This is roughly every 128 minimum-sized requests.

The UNIX-domain sockets essentially act like a shared-memory
transport, so there's no real limit there.

We chose the 4K output buffer size a long time ago because
we just didn't care, and wanted XCB to be usable on very
small devices.  I'm not so up for having some run-time
mechanism to be able to configure the buffer size, because
it introduces some complications and is almost never needed,
but there probably should be a config option to change it
when compiling for a platform, and the default could then be
something like 256K rather than 4K.  Jamey or Josh?

> > Could the BigRequest extension used for this?
> 
> No, but take a look at MIT-SHM. Of course, MIT-SHM would
> be a lot more efficient if you could put all your tiles
> into one large image first.  Just remember that you have
> to keep your old code path as a fallback just in case you
> can't use MIT-SHM (remote display, for example).

Even if you can't tile, this should help a lot, taking you
from about 8 images per switch to about 128 as per above.
Just allocate enough shared memory for 128 pixmaps and off
you go.

> Also, don't copy that abysmal Red Hat Notifier which keeps
> doing a PutImage on the same tiles over and over
> again. Pixmaps exist for a reason.

Amen to that. :-)

    Bart


More information about the Xcb mailing list