The Adaptive Replacement Cache (ARC) is a component of the ZFS file system that stores frequently accessed data in memory to improve performance. On FreeBSD, the ARC size can be set using the “kern.vm.zfs.arc_max” sysctl.
You can check the current ARC size by running the following command:
sysctl kern.vm.zfs.arc_max
You can set the ARC size to a specific value by running the following command:
sysctl kern.vm.zfs.arc_max=value
Where “value” is the size of the ARC in bytes. For example, to set the ARC size to 4GB:
sysctl kern.vm.zfs.arc_max=4294967296
You can also set the value in human readable format using k as kilobytes, M as megabytes, G as Gigabytes etc. For example to set it to 4GB:
sysctl kern.vm.zfs.arc_max=4G
It is important to note that the ARC size should be set based on the amount of memory available on the system and the workloads running on it. A larger ARC size may improve performance, but it also may cause the system to use more memory, potentially leading to memory pressure.
It is also a good idea to set arc_meta_limit, which is the limit for metadata cache. It can also be set in a similar way as arc_max.
sysctl kern.vm.zfs.arc_meta_limit=value
You can also add these settings to /etc/sysctl.conf so that they are automatically set at boot time.
kern.vm.zfs.arc_max=4G
kern.vm.zfs.arc_meta_limit=1G
Keep in mind that ZFS ARC size should be adjusted based on the workload, so it is always good to monitor the memory usage and adjust the settings accordingly.