ZFS using minimum RAM

Hi

I have a NAS, which runs linux. I have ZFS installed

I’ve set it up with /etc/modprobe.d/zfs.conf to use 18GB of ram minimum, but 32GB maximum.

Everytime I look at it though, it appears to only use the minimum, regardless of the system having basically another 32GB free. Does anyone know why this would be?

I thought ZFS would automatically utilise that space if available? Am I missing something?

Obviously I want that RAM to be utilised…And I’m sure if I go in and change the minimum, then more WOULD be used

Where do you look at it? Move 32GB of files around and post arc_summary -s arc

I like to use htop. There are meters for both ARC and compressed ARC stats. With both active, you get a good overview of whats going on.

1 Like

I usually look at it with arc_summary

Shouldn’t it cache without moving the files around? Honestly the NAS barely has any traffic

ARC only caches things that have previously been used. So after a reboot the ARC is basically empty. If you access data, it gets copied into ARC and is cached in later reads. MRU/MFU algorithms ensure that the most important data is kept in the ARC, while less often/recently used stuff gets evicted. But as long as the ARC didn’t reach the Maximum size yet, everything will enter ARC.

Yeah. 19GB used out of 32GB.

I never set a minimum because ARC never cedes those 10GB to the OS and other applications, potentially causing problems.

2 Likes

Is this the case for minimum though? i.e. if I reboot, is it not going to go through and fill that 18GB?

No. Minimum only defines the amount of space that can be given back to the OS if applications demand memory. ARC will shrink adaptively depending on what other applications need and will refuse to do so after it reached its minimum.

ARC is memory and memory is wiped on reboot. There is no record kept on HDDs or where ever. You can warm up the ARC with some scripts on boot with pre-defined files/directories if this helps.

3 Likes

The only part of the ARC system that can be persistent to my knowledge is L2ARC https://github.com/openzfs/zfs/pull/9582

4 Likes

I understand it isn’t persistent, I just assumed it would actively try to fill that space.

I guess it makes sense that it is always low utilisation, as I’m currently having frequent reboots and it has very very light traffic

Presumably by mocking some reads on certain files/folders

No it doesn’t do that and I am not sure if I really want the extra bookkeeping, especially since zfs can be nice on desktop systems also but for that I want a more dynamic ARC. I would go the warm-up way that @Exard3k mentioned or just leave it until your reboot intervals go down.

The problem is…what data should be proactively put into the ARC? You certainly can’t move the entire pool into memory. And even if you keep track of blocks that have been accessed a month ago, which is extra metadata for bookkeeping, your habits may have changed and you always have that 20GB of e.g. Elden Ring game files preloaded into ARC although you don’t play it anymore.

ARC is designed for servers that run 24/7 to improve cache hits over time and adapt dynamically to your workload without too much overhead.

If you’re feeling that persistence and cached reads are important while having regular reboots, consider using an SSD as L2ARC and enable persistent L2ARC. I have a rather big L2ARC and I see good performance after reboot, not memory speeds, but certainly not slow HDD performance.

ARC is great, but needs time to fill and figure out what’s important data.

2 Likes

I’m not sure I’ll go down that route, I don’t really want to spend any more money at this point. I’ll just attempt to have more up time for now

Out of interest though; how to does caching between L2ARC and ARC work?

Presumably your persistent L2ARC has contains those less important items than your primary ARC cache?

Correct. Once ARC is at maximum, it has to decide what data to keep and what to delete/evict. Everything that gets evicted from of the ARC, gets moved to the L2ARC and some bookkeeping is left inside the ARC so it knows “hey I don’t have that data, but I put it into L2ARC. No need to get it from HDD”.
A certain amount of data that is close to eviction also gets stored in the L2ARC, so ARC can delete it if necessary without having the pressure of waiting for the L2ARC to store it. Makes the transition very smooth

Just because it was evicted doesn’t mean it’s not important data. But it’s more data than your memory can handle.

3 Likes

Brilliant. Thanks for your help on this.

I don’t suppose either of you have any tips for not rebooting? I guess there is ways to do most things without reboot apart from kernel updates (Not updating the kernel often?)

I’m running Proxmox and I reboot like every two weeks to get updates. But if the system is running fine and you don’t have open ports to the internet, there is no need to reboot a NAS or server. Linux and ZFS will do fine running for months if not years.

ZFS can only cache stuff you’ve actually demanded.

If you haven’t requested > 18 GB of different content then it won’t be in the cache.

1 Like

I don’t suppose you have an example of this type of script?

1 Like

cp -a /folder/important /dev/null

:grinning:

1 Like

https://utcc.utoronto.ca/~cks/space/blog/linux/ZFSOnLinuxARCShrinkage

It sounds like you’re having something similar happen here. The ZFS target size reduces over time, so the ARC never uses the maximum configured size.

Are you acessing the same files over and over again, or are you reading lots of large, different files? The latter doesn’t really need a large ARC, and may be why ZFS is not trying to push the target size back up.

Be aware that trying to pre-warm cache can be counter-productive if you’re

  • pre-warming the wrong data - either files you think are hot that aren’t - or potentially files that aren’t hot at the time you think they are and potentially evicting other more relevant data already in the cache
  • pre-warming data that may be relevant but not what end users are actually requesting during the pre-warming (e.g., you are attempting to pre-cache folder A whilst user is actually right then trying to access folder B
  • ZFS can cache at the block (i.e., parts of files) level as users request said blocks - by copying files you’re pre-caching entire files which may reduce cache effectiveness

I’d just let it cache as required.

1 Like