Compression on the backing device?
Compression on the backing device?
Posted Feb 20, 2026 1:25 UTC (Fri) by PeeWee (subscriber, #175777)Parent article: Modernizing swapping: virtual swap spaces
The one problem I have with zswap is that it cannot push out compressed folios as-is. The explanation for this is covered briefly in this article: hides behind frontswap. I don't see virtual swap space changing anything about that, because once a folio gets pushed to the backing device the swap subsystem needs to be able to swap it in as if there were no zswap to begin with.
On a more general note, why has nobody ever thought of compressed swap on the actual backing device? Experience with transparent filesystem compression suggests performance gains for rather little CPU time, since the actual I/O is reduced by the compression ratio. LZ4 is an essentially free I/O booster; very fast at decent compression ratio. I also think that ZStandard fits that bill at even greater compression ratios, albeit at higher CPU cost, so why not invest some of the time spent I/O-waiting on making that wait shorter and gain effective capacity? In the case of zswap that work will already have been done, so it's just the writeback that improves without additional penalty. Arguably, decompression upon writeback is an unfair penalty for zswap; it's just that in real world workloads it doesn't figure because it happens very rarely and, with the proactive shrinker, at (more) opportune occasions. This could also eliminate LRU inversions when the zpool limit gets hit hard, because to get to the backing store a folio must go through compression first; while the LRU entry gets written back to make room for it in the zpool. As it stands, zswap is a great improvement but, due to its implementation details (frontswap), it cannot go further. Couldn't this virtual swap space just point to zswap entries regardless if they are in RAM or on the backing device? If such an entry is encountered, have zswap decompress it, i.e. go through frontswap in reverse? This is much like when zswap gets disabled at runtime: new folios will just go directly to and from the backing device but the already compressed ones are kept and treated accordingly. In the long run, I think zswap could become the default that way. Don't want compression? Set some dummy compressor to get legacy behavior. Is all this just too much complexity/overhead, or do kernel devs have such approach on their wish list as well?
