LWN.net Logo

Why not have X-Windows store the COMPRESSED image?

Why not have X-Windows store the COMPRESSED image?

Posted Jun 28, 2006 20:16 UTC (Wed) by dwheeler (subscriber, #1216)
Parent article: Interview: Jim Gettys (Part I)

One question, maybe the interviewer can ask Gettys - why not just have X-Windows store the COMPRESSED image? He notes that "many applications seem to think that storing pixmaps in the X server (and often forgetting about them entirely) is a good strategy, whereas retransmitting or repainting the pixmap may be both faster and use less memory.", and he mentions Federico Mena-Quintera's work. But if they're stored in the client, and sent each time to X-Windows, you now have to at least resend... and X-Windows isn't always local; over a mesh in particular you DON'T want the image retransmitted each time. If you have to store it anyway, why not have X-Windows store compressed, not uncompressed images? Indeed, if X-Windows could accept common compressed formats, and recompress when it feels like it, it could have all the memory benefits he notes...!


(Log in to post comments)

Why not have X-Windows store the COMPRESSED image?

Posted Jun 28, 2006 21:56 UTC (Wed) by allesfresser (subscriber, #216) [Link]

Possibly the compression and decompression would eat a lot of CPU, and therefore power, which would be bad. I could see that being the case, especially if there's a lot of not-very-compressible pixmaps floating around.

Why not have X-Windows store the COMPRESSED image?

Posted Jun 28, 2006 21:58 UTC (Wed) by Yorick (subscriber, #19241) [Link]

That would certainly decrease memory usage but perhaps not at much as regenerating the
pixmaps. A compressed image is just a subroutine written in a very compact language
specialised for generating broad classes of images. The application's own code and data to
regenerate the pixmaps are in most cases already in memory, and the code can usually be more
efficient than a compressor would be as it is adapted to its purpose.

I could definitely imagine compressed pixmaps being a useful way to lower the memory
requirements of existing applications. It just needs some heuristics to avoid compressing those
used frequently.

On a lower level, compressing memory pages that would normally have been swapped out to
disk could make sense on a swapless machine. (This could be an interesting kernel project.)

Why not have X-Windows store the COMPRESSED image?

Posted Jun 29, 2006 2:20 UTC (Thu) by dlang (subscriber, #313) [Link]

what compression algorithm are you thinking of useing?

remember that for this you have to use a lossless compression, and those are famous for having different behavior on different sets of data.

however, the real problem is that X is doing exactly what it's been told to do. programs should know what images are worth keeping anround and which ones aren't, too many of them default to keepign lots of things around and never useing them.

it may be an interesting thing to explore storing these pixmaps on the video card itself, I don't know if the current X drivers can support this or not.

Why not have X-Windows store the COMPRESSED image?

Posted Jun 29, 2006 2:41 UTC (Thu) by guinan (subscriber, #4644) [Link]

There was an X Image Extention (XIE) some time ago, which basically
did what you're describing, but it got deleted from the tree in
X11R6.7.0.

I googled but couldn't find a definitive reason why it was deleted,
but I gather it wasn't popular with some developers.

Why not have X-Windows store the COMPRESSED image?

Posted Jun 29, 2006 9:52 UTC (Thu) by jg (subscriber, #17537) [Link]

It is a good question.

Care to work on a compressed image transport extension? Then storing
compressed images in the server would probably be straightforward.

I warn you that the last time this was attempted, that the people doing
XIE slipped down the slippery slope into complexity hell, to the point that
XIE is no more.

None the less, it is on the list of things I'd like to see/have: care to work on it?

BTW, on a local machine, moving the images is *really* fast. Just clock
it sometime.

Why not have X-Windows store the COMPRESSED image?

Posted Jun 29, 2006 10:08 UTC (Thu) by kleptog (subscriber, #1183) [Link]

The big problem is that these images are stored so they can be quickly blitted to the screen. What graphics cards do you know that support lossless compression on images. Many would support JPEG/MPEG style, but lossless compression is a pain. Especially when you're going to want to read individual pixels from it (consider if a window partially overlaps the image you want to display).

Personally I think more use should be made of the XShm extension, when the client stores the images in shared memory and the X server can see them. One thing graphics processors can do is blit images and convert colour and layout on the fly.

I think what would really help is a way to see what pixmaps (and other resources) are currently stored in the server. That would make it easier to see if anything is being leaked.

Why not have X-Windows store the COMPRESSED image?

Posted Jun 29, 2006 20:50 UTC (Thu) by oak (subscriber, #2786) [Link]

> Personally I think more use should be made of the XShm extension,
> when the client stores the images in shared memory and the X server
> can see them. One thing graphics processors can do is blit images
> and convert colour and layout on the fly.

The X client memory is main RAM on the machine, X server memory
is (partly) memory on the graphics card. I.e. at least the graphics
needs to be copied from the client SHM memory to the gfx card memory
before blitting on screen. However, I don't think this is an issue
compared to the issue of app keeping images redundantly in memory and
making the whole machine swap...

Probably one reason why apps store so much images to the X server
is that this way the images can be blit much faster when the app
is using X server remotely. Faster networks make copying image data
from the remote client to X server less of an issue but maybe with
server side images there's less latency? (which is the real killer
of UI responsiveness with remote X)


> I think what would really help is a way to see what pixmaps
> (and other resources) are currently stored in the server.
> That would make it easier to see if anything is being leaked.

There is already a such thing. There's a patch to the X resource
extension and simple utility for showing the listed pixmaps.
It was mentioned in one of the optimization blogs I think.

Btw. For measuring application response times (e.g. to see whether
performance optimization had an effect), there's a tool called
"xresponse" (it outputs timestamped "X damage" i.e. screen updates
events).

Why not have X-Windows store the COMPRESSED image?

Posted Jul 2, 2006 7:30 UTC (Sun) by giraffedata (subscriber, #1954) [Link]

There's no such thing as X-Windows. There's X (full name: The X Window System) and there's Windows (Microsoft).

Why not have X-Windows store the COMPRESSED image?

Posted Jul 5, 2006 1:52 UTC (Wed) by k8to (subscriber, #15413) [Link]

Great. You're pedantically correct.

However, knowing this, we non-pedantic long-time Unix users still call it X Windows all the time, along with other names.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.