首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ZRAM和ZSWAP的区别

ZRAM和ZSWAP的区别
EN

Stack Overflow用户
提问于 2013-08-26 13:28:17
回答 2查看 28.1K关注 0票数 32

有人知道linux内核中的ZRAM和ZSWAP有什么区别吗?它们看起来非常相似--在ram中存储压缩的页面。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-08-26 13:41:44

Linux ZRAM是内核的一个模块,以前称为“compcache.”。ZRAM通过避免磁盘上的分页来提高性能,而是使用RAM中的压缩块设备,在该设备中进行分页,直到需要使用硬盘驱动器上的交换空间为止。由于使用RAM比使用磁盘更快,因此zram允许Linux在需要交换/分页时更多地使用RAM,特别是在安装了较少RAM的旧计算机上。

ZSWAP是一个用于交换页面的轻量级压缩缓存。它接收正在被换出的页面,并尝试将它们压缩到动态分配的基于RAM的内存池中。zswap基本上是用CPU周期来换取可能减少的交换I/O。如果从压缩缓存读取的速度比从交换设备读取的速度快,这种权衡也可以显著提高性能。

票数 16
EN

Stack Overflow用户

发布于 2013-09-04 02:04:25

zram

主线内核中提供

  • Status:从版本3.14开始(三月2014)
  • Implementation:压缩块设备,内存在数据被交换时动态分配将zram块设备配置为交换设备,以消除对物理交换设备或交换file
  • Benefits

的需求

代码语言:javascript
复制
1. Eliminates need for physical swap device. This beame popular when netbooks first showed up. Zram (then compcache) allowed users to avoid swap shortening the lifespan of SSDs in these memory constrained systems.
2. A zram block device can be used for other applications other than swap, anything you might use a block device for conceivably.

  • Drawbacks

代码语言:javascript
复制
1. Once a page is stored in zram it will remain there until paged in or invalidated. The first pages to be paged out will be the oldest pages (LRU list), these are 'cold' pages that are infrequently access. As the system continues to swap it will move on to pages that are warmer (more frequently accessed), these may not be able to be stored because of the swap slots consumed by the cold pages. What zram can not do (compcache had the option to configure a block backing device) is to evict pages out to physical disk. Ideally you want to age data out of the in-kernel compressed swap space out to disk so that you can use kernel memory for caching warm swap pages or free it for more productive use.

zswap

从3.11版本开始,主线内核中提供了

  • Status:(9月2013)
  • Implementation:压缩的内核内缓存,用于交换页面。内核缓存是压缩的,压缩算法是可使用CryptoAPI插入的,页面存储是动态分配的。可以将较旧的页面逐出到磁盘,使其成为一种用于常规交换设备(或交换files).
  • Benefits

)的写后cache.

  • Usage:缓存交换页面

代码语言:javascript
复制
1. Integration with swap code (using Frontswap API) allows zswap to choose to store only pages that compress well and handle memory allocation failures, in those cases pages are sent to the backing swap device.
2. Oldest pages in the cache are pushed out to backing swap device to make room for newer pages, this solves the LRU inversion problem that a lack of page eviction would present.

  • Drawbacks

代码语言:javascript
复制
1. Needs a physical swap device (or swapfile).

票数 53
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18437205

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档