Creating compressed backing_store as swapfile

Austin S. Hemmelgarn ahferroin7 at gmail.com
Mon Nov 5 11:28:49 EST 2018


On 11/5/2018 11:14 AM, valdis.kletnieks at vt.edu wrote:
> On Mon, 05 Nov 2018 11:07:12 -0500, "Austin S. Hemmelgarn" said:
> 
>> Performance isn't _too_ bad for the BTRFS case though (I've actually
>> tested this before), just make sure you disable direct I/O mode on the
>> loop device, otherwise you run the risk of data corruption.
> 
> Did you test that for random-access. or just sequential read/write?
> (Also, see the note in my other mail regarding doing a random-access
> write to the middle of the file...)
> 
Actual swap usage.  About 16 months ago, I had been running a couple of 
Intel NUC5PPYH boxes (Pentium N3700 CPU's, 4GB of DDR3-1333 RAM) for 
some network prototyping.  On both, I had swap set up to use a file on 
BTRFS via a loop device, and I made a point to test both with LZ4 inline 
compression and without any compression, and saw negligible performance 
differences (less than 1% in most cases).  It was, of course, 
significantly worse than running on ext4, but on a system that's so 
resource constrained that both storage and memory are at a premium to 
this degree, the performance hit is probably going to be worth it.

Also, it's probably worth noting that BTRFS doesn't need to decompress 
the entire file to read or write blocks in the middle, it splits the 
file into 128k blocks and compresses each of those independent of the 
others, so it can just decompress the 128k block that holds the actual 
block that's needed.



More information about the Kernelnewbies mailing list