To read all comments associated with this story, please click here.
This is a key point!
The "idiocy" comment in the original posting was way off-base. The XImage system actually makes a ton of sense. In most apps, you're drawing the same images over and over again (sprites, chrome). Its not a big deal to transfer them to the X server the first time they're drawn. In a web-browser context, you're drawing different images all the time, but what do you think is the bottleneck, copying the image to the X server, or downloading them from the internet?
Where XShm helps is when you dynamically generate images for each frame, and as such are constantly uploading new images to the Xserver to draw. However, even in that case, it is unlikely to provide a huge speedup, since the overall time is probably dominated by creating the image, not copying it to the X server.
There's an additional big problem with sockets: Once you send the image to the server, the client can't "share" it, because it's living in the server's address space. So you have a copy of the image on the server AND exactly the same copy of the image on the client. The image is effectively using 2x its size in the memory.
The "right fix" for this stupid waste of resources is to free() the image on the client. With shared memory, you can SHARE the image's memory between the client and the process.
That's how things should work on a sane local graphic setup, but X is far from being "sane". Yes, X.org IS efficient and comparable to other systems, but only because people have spent a lot of time workarounding the stupid things it does so that at the end in local systems it works like other sane systems.
That's the funny thing: X is supposed to be "network transparent", but then the server and the client need to DETECT if they're in "local mode", or if such extension is enabled or not, and make SPECIAL MODIFICATIONS to the code paths so that it works right. There's no "transparency" anymore, as applications (toolkits) need to be aware of such low-level graphic details and code different paths according to the results. It has been needed to create many X extensions, it has been needed to MODIFY applications to use those extensions...oh my god, it's just not fun even to think about it. And to think that backwards compatibility is all that was stopping people from doing it right...
Edited 2008-06-29 09:20 UTC
Well, we are speaking about Cairo here right?
Cairo is basically a software renderer. That implies that in fact you do all your rendering to the memory, then transfer the resulting image to X11.
That in fact implies that you rarely are able to "reuse" stored images. Each screen update means a new image and new transfer.
IME, the difference in image transfer is about 2x. OTOH, the rendering itself can perhaps take quite a bit of time too, so in practice, maybe it really is not that critical.
BTW, you can try it:
x11perf -putimage500
x11perf -shmput500
Fedora 9 with all updates, redeon driver, AMD 3870, Phenom 9750
[storm@fast ~]$ x11perf -putimage500
x11perf - X11 performance program, version 1.5
The X.Org Foundation server version 10499902 on :0.0
from fast
Sun Jun 29 14:11:16 2008
Sync time adjustment is 0.0334 msecs.
2800 reps @ 2.0214 msec ( 495.0/sec): PutImage 500x500 square
2800 reps @ 1.9846 msec ( 504.0/sec): PutImage 500x500 square
2800 reps @ 1.9471 msec ( 514.0/sec): PutImage 500x500 square
2800 reps @ 1.9314 msec ( 518.0/sec): PutImage 500x500 square
2800 reps @ 1.9462 msec ( 514.0/sec): PutImage 500x500 square
14000 trep @ 1.9661 msec ( 509.0/sec): PutImage 500x500 square
[storm@fast ~]$ x11perf -shmput500
x11perf - X11 performance program, version 1.5
The X.Org Foundation server version 10499902 on :0.0
from fast
Sun Jun 29 14:12:17 2008
Sync time adjustment is 0.0305 msecs.
16000 reps @ 0.3851 msec ( 2600.0/sec): ShmPutImage 500x500 square
16000 reps @ 0.3684 msec ( 2710.0/sec): ShmPutImage 500x500 square
16000 reps @ 0.3661 msec ( 2730.0/sec): ShmPutImage 500x500 square
16000 reps @ 0.3684 msec ( 2710.0/sec): ShmPutImage 500x500 square
16000 reps @ 0.3680 msec ( 2720.0/sec): ShmPutImage 500x500 square
80000 trep @ 0.3712 msec ( 2690.0/sec): ShmPutImage 500x500 square
~5 times faster, not bad.





Member since:
2005-07-07
I think the article is exaggerating the problem.
True, transferring an image from the application to the X server takes quite some time and can be sped up using the shared memory extension.
However, an image does not have to be transferred every time it needs to be drawn.
As long as the application does not explicitly free the resources associated with the X server side image, it can be drawn or bitblitted with basically no delay.