10

I want to use a high-speed swap device or zram as "page cache", so that page data can be dropped automatically when the system is out of memory.

Apparently, zcache has been discontinued. Is there an available alternative? If yes, which one?

bcache doesn't seem to drop data when there's no memory available.

5
  • 1
    How do you define "page cache"? Do you mean memory management scheme, a.k.a. swap? If so, bcache has nothing to do with it. Jun 27 '17 at 14:23
  • You English is difficult to understand, and you seem to mix unrelated concepts, so the noise level in your question is rather high. That's why I asked for clarification. Jun 30 '17 at 16:57
  • You ask about how to use swap device as "page cache". You control which swap devices the kernel should use (and their priorities) with swapon and swapoff commands. It doesn't matter what is the actual storage for the device, whether it is a zram, disk partition, or bcache. Jun 30 '17 at 16:59
  • I'm sorry for my express way,in fact I trying find a alternative for zcache @AdamRyczkowski thank you.
    – illiterate
    Jul 1 '17 at 4:49
9

Indeed zcache appears to have been discontinued, as it was removed from kernel 3.11 for being effectively obsolete. The commit message of zcache removal reads

staging: zcache: delete it

zcache is obsolete and not used anymore, Bob Liu has rewritten it and is submitting it for inclusion through the main -mm tree, as it should have been done in the first place...

It appears that Bob Liu's submission never got into mainline.

Now, the way I understand it, the page cache is automatically "dropped" (cleared) in an out-of-memory scenario. zcache actually implemented compression so it could maintain more filesystem pages (also known as "vfs cache" or "inode/dentry cache") before being dropped.

The Linux kernel has zswap today that implements compressed disk-based swapping, but doesn't compress filesystem pages.

I am not aware of a current day alternative for zcache.

Perhaps as a workaround, if you are concerned with performance degradation due to filesystem pages being freed, consider tuning vm.vfs_cache_pressure as instructed here.

For normal workloads it's safe to just settle with zswap.

Additional reading:

  1. zram vs zswap vs zcache Ultimate guide: when to use which one
  2. Zswap, Zram, Zcache desktop usage scenarios
  3. zswap (Arch Linux Wiki)
  4. Cleancache and Frontswap (LWN)
  5. The Case for Compressed Caching in Virtual Memory Systems
0

NVMe? -hardware fix
BTRFS Compression? -software fix

Now that NVMe disks can be accessed so fast, the CPU is approaching bottlnecking uncompressed transfers. Compression may hinder performance.

BTRFS Compression helps.

Spinning-Rust should be largely replaced by now with faster storage and limited to archival purposes.

2
  • 2
    In my experience, if you need any performance, avoid btrfs. It sure has nice features but performance is not one of those. If you need high performance on spinning rust, try ext4 or XFS instead. For example, see phoronix.com/… May 11 '20 at 9:15
  • I don't think that's the issue here, but if you do prefer FS features over raw performance, use ZFS instead. It already saved my data once where btrfs couldn't have had, and it's not linux-specific. (EDIT: the "spinning rust" moniker is cute but evidently and inherently wrong.)
    – RJVB
    Jul 12 '20 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.