Skip to content

Commit

Permalink
Reinstate zfs_arc_p_min_shift
Browse files Browse the repository at this point in the history
Commit f521ce1 removed the minimum value for "arc_p" allowing it to
drop to zero or grow to "arc_c".  This was done to improve specific
workload which constantly dirties new "metadata" but also frequently
touches a "small" amount of mfu data (e.g. mkdir's).

This change may still be desirable but it needs to be re-investigated.
in the context of the recent ARC changes from upstream.  Therefore
this code is being restored to facilitate benchmarking.  By setting
"zfs_arc_p_min_shift=64" we easily compare the performance.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#3533
  • Loading branch information
behlendorf committed Jul 23, 2015
1 parent 36da08e commit 728d6ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
12 changes: 12 additions & 0 deletions man/man5/zfs-module-parameters.5
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,18 @@ the reclaim thread catches up and the overflow condition no longer exists.
Default value: \fB8\fR.
.RE

.sp
.ne 2
.na

\fBzfs_arc_p_min_shift\fR (int)
.ad
.RS 12n
arc_c shift to calc min/max arc_p
.sp
Default value: \fB4\fR.
.RE

.sp
.ne 2
.na
Expand Down
16 changes: 14 additions & 2 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ static int arc_grow_retry = 5;
/* shift of arc_c for calculating overflow limit in arc_get_data_buf */
int zfs_arc_overflow_shift = 8;

/* shift of arc_c for calculating both min and max arc_p */
static int arc_p_min_shift = 4;

/* log2(fraction of arc to reclaim) */
static int arc_shrink_shift = 7;

Expand Down Expand Up @@ -230,6 +233,7 @@ unsigned long zfs_arc_meta_limit = 0;
unsigned long zfs_arc_meta_min = 0;
int zfs_arc_grow_retry = 0;
int zfs_arc_shrink_shift = 0;
int zfs_arc_p_min_shift = 0;
int zfs_disable_dup_eviction = 0;
int zfs_arc_average_blocksize = 8 * 1024; /* 8KB */

Expand Down Expand Up @@ -3718,6 +3722,7 @@ static void
arc_adapt(int bytes, arc_state_t *state)
{
int mult;
uint64_t arc_p_min = (arc_c >> arc_p_min_shift);
int64_t mrug_size = refcount_count(&arc_mru_ghost->arcs_size);
int64_t mfug_size = refcount_count(&arc_mfu_ghost->arcs_size);

Expand All @@ -3738,7 +3743,7 @@ arc_adapt(int bytes, arc_state_t *state)
if (!zfs_arc_p_dampener_disable)
mult = MIN(mult, 10); /* avoid wild arc_p adjustment */

arc_p = MIN(arc_c, arc_p + bytes * mult);
arc_p = MIN(arc_c - arc_p_min, arc_p + bytes * mult);
} else if (state == arc_mfu_ghost) {
uint64_t delta;

Expand All @@ -3747,7 +3752,7 @@ arc_adapt(int bytes, arc_state_t *state)
mult = MIN(mult, 10);

delta = MIN(bytes * mult, arc_p);
arc_p = MAX(0, arc_p - delta);
arc_p = MAX(arc_p_min, arc_p - delta);
}
ASSERT((int64_t)arc_p >= 0);

Expand Down Expand Up @@ -5265,6 +5270,10 @@ arc_tuning_update(void)
arc_no_grow_shift = MIN(arc_no_grow_shift, arc_shrink_shift -1);
}

/* Valid range: 1 - N */
if (zfs_arc_p_min_shift)
arc_p_min_shift = zfs_arc_p_min_shift;

/* Valid range: 1 - N ticks */
if (zfs_arc_min_prefetch_lifespan)
arc_min_prefetch_lifespan = zfs_arc_min_prefetch_lifespan;
Expand Down Expand Up @@ -6996,6 +7005,9 @@ MODULE_PARM_DESC(zfs_arc_p_dampener_disable, "disable arc_p adapt dampener");
module_param(zfs_arc_shrink_shift, int, 0644);
MODULE_PARM_DESC(zfs_arc_shrink_shift, "log2(fraction of arc to reclaim)");

module_param(zfs_arc_p_min_shift, int, 0644);
MODULE_PARM_DESC(zfs_arc_p_min_shift, "arc_c shift to calc min/max arc_p");

module_param(zfs_disable_dup_eviction, int, 0644);
MODULE_PARM_DESC(zfs_disable_dup_eviction, "disable duplicate buffer eviction");

Expand Down

0 comments on commit 728d6ae

Please sign in to comment.