Score:1

zfs: flush cache without exporting

ar flag

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.

Score:2
ca flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.