From 49ddb315066e372f31bda29a5c546a9eccc8b418 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Wed, 20 Aug 2014 10:09:40 -0700 Subject: [PATCH] Illumos 5034 - ARC's buf_hash_table is too small 5034 ARC's buf_hash_table is too small Reviewed by: Christopher Siden Reviewed by: George Wilson Reviewed by: Saso Kiselkov Reviewed by: Richard Elling Approved by: Gordon Ross References: https://www.illumos.org/issues/5034 https://github.com/illumos/illumos-gate/commit/63e911b Ported-by: Brian Behlendorf Closes #2615 --- man/man5/zfs-module-parameters.5 | 16 ++++++++++++++++ module/zfs/arc.c | 13 ++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/man/man5/zfs-module-parameters.5 b/man/man5/zfs-module-parameters.5 index d23e8022a..4671c396f 100644 --- a/man/man5/zfs-module-parameters.5 +++ b/man/man5/zfs-module-parameters.5 @@ -274,6 +274,22 @@ Min time before an active prefetch stream can be reclaimed Default value: \fB2\fR. .RE +.sp +.ne 2 +.na +\fBzfs_arc_average_blocksize\fR (int) +.ad +.RS 12n +The ARC's buffer hash table is sized based on the assumption of an average +block size of \fBzfs_arc_average_blocksize\fR (default 8K). This works out +to roughly 1MB of hash table per 1GB of physical memory with 8-byte pointers. +For configurations with a known larger average block size this value can be +increased to reduce the memory footprint. + +.sp +Default value: \fB8192\fR. +.RE + .sp .ne 2 .na diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 7c3bebabe..2c7abe6ec 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -193,6 +193,9 @@ int zfs_arc_memory_throttle_disable = 1; /* disable duplicate buffer eviction */ int zfs_disable_dup_eviction = 0; +/* average block used to size buf_hash_table */ +int zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ + /* * If this percent of memory is free, don't throttle. */ @@ -1003,10 +1006,11 @@ buf_init(void) /* * The hash table is big enough to fill all of physical memory - * with an average 64K block size. The table will take up - * totalmem*sizeof(void*)/64K (eg. 128KB/GB with 8-byte pointers). + * with an average block size of zfs_arc_average_blocksize (default 8K). + * By default, the table will take up + * totalmem * sizeof(void*) / 8K (1MB per GB with 8-byte pointers). */ - while (hsize * 65536 < physmem * PAGESIZE) + while (hsize * zfs_arc_average_blocksize < physmem * PAGESIZE) hsize <<= 1; retry: buf_hash_table.ht_mask = hsize - 1; @@ -5657,6 +5661,9 @@ MODULE_PARM_DESC(zfs_arc_shrink_shift, "log2(fraction of arc to reclaim)"); module_param(zfs_disable_dup_eviction, int, 0644); MODULE_PARM_DESC(zfs_disable_dup_eviction, "disable duplicate buffer eviction"); +module_param(zfs_arc_average_blocksize, int, 0444); +MODULE_PARM_DESC(zfs_arc_average_blocksize, "Target average block size"); + module_param(zfs_arc_memory_throttle_disable, int, 0644); MODULE_PARM_DESC(zfs_arc_memory_throttle_disable, "disable memory throttle");