0

I want to use virtual memory for ARC ZFS write cache, because it is troublesome for me to increase physical memory but I want fast writing to a DB in a ZFS.

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          3.8Gi       809Mi       2.4Gi       3.0Mi       564Mi       2.8Gi
Swap:           9Gi          0B         9Gi
$ arcstat
    time  read  miss  miss%  dmis  dm%  pmis  pm%  mmis  mm%  size     c  avail
08:28:46     0     0      0     0    0     0    0     0    0  414M  762M   2.6G

You see, it can use only 2.6G instead of more that I want:

$ cat /sys/module/zfs/parameters/zfs_arc_min
8159637832
$ cat /sys/module/zfs/parameters/zfs_arc_max
10199547290

What's wrong?

Ubuntu 21.

1 Answer 1

2

The ARC can only use physical memory, which is why it’s “only” 2.6G on your system.

It wouldn’t be useful to cache in swap — writing and reading swap isn’t going to be any faster than writing and reading the actual storage. (I’m ignoring things like ZRAM here but that’s not particularly relevant for ZFS anyway.)

3
  • It would be faster because swap is SSD and actual storage is HDD. And why doesn't Linux support ARC in swap? That would be useful.
    – porton
    Oct 31, 2021 at 10:28
  • 1
    If you want to use an SSD as cache in front of HDDs, you should set up an L2ARC. ARC in swap isn’t supported in ZFS (nothing to do with Linux) because there are better solutions. Oct 31, 2021 at 10:40
  • 1
    +1. Also, for "fast writing to a DB" it's useful to add a small (2-4 GB is good) partition of the SSD as a log device (aka "SLOG") to the zpool. Databases are usually written to sync all writes immediately, and zfs log devices are used as a write cache for sync writes. An alternative to a small partition on your main SSD would be to use an extremely fast NVME SSD, like an Intel Optane drive - or a small partition on one, they're small but still much larger than needed...the SLOG gets flushed every 5 or 10 seconds by default, and there's no benefit in having an over-sized log device.
    – cas
    Nov 1, 2021 at 4:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .