zram
Initial release | March 30, 2014 | (Linux 3.14)
---|---|
Written in | C |
Operating system | Linux |
Type | Linux kernel features |
License | GNU General Public License |
Website | www |
zram, formerly called compcache, is a
/tmp
) and as a swap device. Initially, zram had only the latter function, hence the original name "compcache" ("compressed cache"). Unlike swap, zram only uses 0.1% of the maximum size of the disk when not in use.[1]After four years in the Linux kernel's driver staging area, zram was introduced into the mainline Linux kernel in version 3.14, released on March 30, 2014.
When used as a compressed swap space, zram is similar to zswap, which is not a general-purpose RAM disk, but rather an in-kernel compressed cache for swap pages. Until the introduction of CONFIG_ZRAM_WRITEBACK
in kernel version 4.14, unlike zswap, zram was unable to use a storage device as a backing store, so it was unable to move less-frequently used pages to disk. However, zswap always requires a backing store, which is not the case for zram.
When used for swap, zram (like zswap) allows Linux to make more efficient use of RAM, since the operating system can then hold more pages of memory in the compressed swap than if the same amount of RAM had been used as application memory or disk cache. This is particularly effective on machines that do not have much memory.
Using compressed swap space with zram or zswap also offers advantages for low-end hardware devices such as
See also
- Swap partitions on SSDs
- Virtual memory compression
References
- ^ "zram: Compressed RAM-based block devices — The Linux Kernel documentation". docs.kernel.org. Retrieved February 25, 2024.
- ^ "Linux kernel 3.14, Section 1.2. zram: Memory compression mechanism considered stable". kernelnewbies.org. March 30, 2014. Retrieved April 1, 2014.
- ^ a b "ZRAM Will See Greater Performance On Linux 5.1 - It Changed Its Default Compressor - Phoronix". www.phoronix.com.
- ^ "Linux kernel 3.15, Section 1.7. zram: LZ4 compression support, improved performance". kernelnewbies.org. June 8, 2014. Retrieved June 15, 2014.
- ^ "Increased performance in Linux with zram (virtual swap compressed in ram)". webupd8.org. October 2, 2011. Retrieved November 8, 2011.
- ^ "compcache Compressed Caching for Linux". code.google.com. April 27, 2010. Retrieved November 11, 2011.
- ^ Dinsan, Francis (December 8, 2012). "Ubuntu Linux Considers Greater Usage of zRAM". Retrieved October 30, 2013.
- ^ "Fedora 33 Looking To Use Swap On zRAM By Default With systemd's zram-generator - Phoronix". www.phoronix.com. Retrieved March 29, 2021.
- Phoronix. August 14, 2013. Retrieved February 9, 2014.
- Phoronix. November 25, 2013. Retrieved February 9, 2014.
External links
- zram Linux kernel documentation and zramctl(8) manual page
- Compcache, Compressed Caching for Linux
- Compcache: in-memory compressed swapping, May 26, 2009, LWN.net, by Nitin Gupta
- In-kernel memory compression, April 3, 2013, LWN.net, by Dan Magenheimer
- The Compression Cache: Virtual Memory Compression for Handheld Computers, March 16, 2000, by Michael J. Freedman