LWN.net Logo

Bitmap cache

Bitmap cache

Posted Jul 28, 2007 13:51 UTC (Sat) by man_ls (subscriber, #15091)
In reply to: Bitmap cache by Los__D
Parent article: Still waiting for swap prefetch

I would never (never EVER) suggest using JPEG for computer graphics
I wouldn't either. My little experiment with JPEG images involved decompressing a JPEG image vs. caching an uncompressed bitmap. Caching images in a lossy format would be ludicrous.

But caching in a lossless format such as PNG isn't such a good idea either. An important aspect of caches is that you should store an artifact which you already have, not one you have to generate. If you have to compress a bitmap to PNG before caching it, you are wasting a lot of CPU time just to generate a cache which you might as well never use again.

An example: you download a JPEG image, then uncompress it to show it, and then you compress it to PNG before caching it in memory. Messy.


(Log in to post comments)

Bitmap cache

Posted Jul 28, 2007 14:00 UTC (Sat) by Los__D (guest, #15263) [Link]

It really depends on the cost of CPU vs. the cost of memory.

For most usage patterns, I agree, but for those that likes to have 30+ tabs open (for some reason), caching the uncompressed bitmap is a _big_ waste.

The question is if the best approach wouldn't be to just forget or limit those caches for that kind of usage. At least the bitmap approach is asking for disk trashing.

Bitmap cache

Posted Oct 9, 2007 18:49 UTC (Tue) by Blaisorblade (guest, #25465) [Link]

I've read time ago a comment from a OLPC developer on exactly this issue. I'm writing a summary of his comments I recall.
Basically, an application can store an uncompressed bitmap in the X server. And Firefox caches all images this way! That's the problem. Probably avoiding the caching would be even faster (due to no swapping).

IMHO (and this is my opinion, I don't recall his one) a reasonable solution would be to extend the X protocol to allow caching compressed images in most reasonable formats (including especially JPEG). Then the X server can keep a cache of most shown decoded images.

Since the JPEG compression ratio is huge, there would be a huge gain from this.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds