LWN.net Logo

zcache: a compressed page cache

zcache: a compressed page cache

Posted Jul 29, 2010 23:56 UTC (Thu) by jzbiciak (✭ supporter ✭, #5246)
In reply to: zcache: a compressed page cache by saffroy
Parent article: zcache: a compressed page cache

The tradeoff skews very heavily in favor of compression these days, at least if you're using a traditional HD.

Hard drive seek times are measured in multiple milliseconds. 1ms is 1 million cycles on a 1GHz CPU. You can do a lot in that time. For every seek you eliminate, you buy back millions and millions of CPU cycles.

As for your GIMP working set? The main gain you'll get there is from the other data in your system compressing, making room for GIMP. And besides, GIMP does its own paging via its tile cache, doesn't it?


(Log in to post comments)

zcache: a compressed page cache

Posted Jul 30, 2010 20:09 UTC (Fri) by joern (subscriber, #22392) [Link]

Actually, hard drives penalize compression as well. You have plenty of bandwidth to waste anyway, so compressing the data to roughly half size does not help much. But with compression, it becomes much nearly impossible to avoid fragmentation. Whenever content changes, the compressed size changes.

Wrt. swap, compression may well end up reducing seeks. But for file backed data, compression costs a lot more performance than the cpu cycles spent in zlib or whereever.

zcache: a compressed page cache

Posted Jul 31, 2010 3:00 UTC (Sat) by jzbiciak (✭ supporter ✭, #5246) [Link]

The tradeoff with swap is that it can delay (and maybe completely avoid) hitting the disk at all. There are plenty of workloads that compression can make fit in RAM, whereas without compression, it can hit the disk a fair bit.

If you take hitting the disk as a given, as is the case with a compressed filesystem with compressed files, then the tradeoffs get much more complex. This is especially true whenyou consider that most files are small relative to disk block sizes.

But with VM, it's about dirty anonymous pages (heap and such). The only reason to push these to disk is that you're trying to use more RAM than is available. Disk acts as RAM overflow. If compression can push the "swap to disk" threshold out, then it is a clearer win.

zcache: a compressed page cache

Posted Jul 31, 2010 6:42 UTC (Sat) by saffroy (subscriber, #43999) [Link]

"There are plenty of workloads that compression can make fit in RAM"

Interesting. Got more details or pointers about this?

zcache: a compressed page cache

Posted Jul 31, 2010 14:34 UTC (Sat) by jzbiciak (✭ supporter ✭, #5246) [Link]

Here's an older one about compcache: https://code.google.com/p/compcache/wiki/Performance/LTSP...

That at least illustrates the principle that compression can keep you from hitting the disk and also increase the size of workload a machine can handles effectively.

zcache: a compressed page cache

Posted Jul 31, 2010 3:04 UTC (Sat) by jzbiciak (✭ supporter ✭, #5246) [Link]

And, I should add that with file-backed pages, it sound like it just compresses the in-memory copies. This defers writeback, which can lead to more contiguous allocations (in the case of new files or files that are getting extended), or for transient files, fewer temp files pushing blocks to disk.

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