Skip to content

Instantly share code, notes, and snippets.

@lundman
Created December 26, 2013 00:14
Show Gist options
  • Save lundman/8128184 to your computer and use it in GitHub Desktop.
Save lundman/8128184 to your computer and use it in GitHub Desktop.
ARC dynamic resize
diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index a26c98d..6ab61c4 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -2487,6 +2487,32 @@ arc_reclaim_thread(void *dummy __unused)
mutex_enter(&arc_reclaim_thr_lock);
while (arc_thread_exit == 0) {
+#ifdef __APPLE__
+#ifdef _KERNEL
+ static uint64_t last_zfs_arc_max = 0;
+ // Detect changes of arc stats from sysctl
+ if (zfs_arc_max != last_zfs_arc_max) {
+ last_zfs_arc_max = zfs_arc_max;
+
+ /*
+ * Allow the tunables to override our calculations if they are
+ * reasonable (ie. over 64MB)
+ */
+ if (zfs_arc_max > 64<<20 && zfs_arc_max < physmem * PAGESIZE)
+ arc_c_max = zfs_arc_max;
+ //if (zfs_arc_min > 64<<20 && zfs_arc_min <= arc_c_max)
+ //arc_c_min = zfs_arc_min;
+ arc_c = arc_c_max;
+ arc_p = (arc_c >> 1);
+
+ /* limit meta-data to 1/4 of the arc capacity */
+ arc_meta_limit = arc_c_max / 4;
+ arc_meta_max = 0;
+ printf("ARC: updating arc_max=%llx\n", arc_c_max);
+ }
+#endif
+#endif
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment