4

For testing I need zfs' cache to be cold.

I can flush caching from the pool by removing the cache disks, exporting and importing the pool. This gives the effect I want. But would really like not to export the pool.

Is there a less drastic way to achieve the same effect?

What I am looking for is the equivalent to:

echo 3 > /proc/sys/vm/drop_caches

which does what I want for ext4.

Background

I can run my algorithm in different ways. I do not care about the best-case performance. I do care about worst-case performance. Worst-case would be on cold data (data touched so long ago that it is no longer in ARC/L2ARC).

To choose the optimal way to run the algorithm, I need to be able to run on the same test set. And this test set must be cold. This goes completely against ZFS' caching strategy: If I run on the same test set again and again, it will put the data into ARC - which makes perfect sense under normal circumstances, but not here.

I can export/import on my developer machine, but I cannot do this in production. Flushing the cache, however, will be acceptable in production.

I will prefer if ARC still works, so the cold data is cached after being read (again similar to ext4), but I can live with ARC completely disabled during the test.

Ole Tange
  • 2,946
  • 6
  • 32
  • 47

1 Answers1

2

echo 3 > /proc/sys/vm/drop_caches used to clear ZFS cache, but some recent commit changed that to only partially clear it.

To restore the old behavior, one has to set the zfs_arc_shrinker_limit module parameters to 0 (see here).

So, to drop ARC without exporting the pool:

echo 0 > /sys/module/zfs/parameters/zfs_arc_shrinker_limit
echo 3 > /proc/sys/vm/drop_caches

The above will drop almost all ZFS ARC, leaving only an handful of MB related to basic pool metadata.

shodanshok
  • 47,711
  • 7
  • 111
  • 180