[PATCH] ZFS not caching on i386 with kmem_size >1GB

David Taylor davidt at yadt.co.uk
Mon Dec 31 15:48:53 PST 2007


Hi,

About 2 months ago I reported that I found ZFS extremely slow for
some tasks (specifically upgrading ports).  This was because ZFS
was only using the absolute minimum cache size at all times.

The problem is here in /sys/contrib/opensolaris/uts/common/fs/zfs/arc.c:

static int
arc_reclaim_needed(void)
{
...
        if (kmem_used() > (kmem_size() * 4) / 5)
                return (1);
}

I'm running on i386 with kmem_size set to 1GB.  As a result, the
multiplication overflows and the test becomes (kmem_used() > 0).  ZFS then
always tries to shrink the cache, and never grows it above the absolute
minimum size (about 30MB for each of c and p)

The patch I have attached fixes the problem for me, although there is probably
a better way to avoid the overflow (without calling kmem_size() twice).
Best of all, portupgrade is now an order of magnitude faster!

Of course, I'm now worried that my previously rock-solid settings will actually
trigger the kmem_map too small panics when the cache actually fills up.

-- 
David Taylor


More information about the freebsd-fs mailing list