[PATCH] ZFS not caching on i386 with kmem_size >1GB
Kris Kennaway
kris at FreeBSD.org
Wed Jan 2 03:09:46 PST 2008
David Taylor wrote:
> 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.
>
FYI, kmem_size > 1GB makes no sense unless you also increase KVA_PAGES
since the entire kernel only has 1GB of address space on i386.
Kris
More information about the freebsd-fs
mailing list