aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-10-11 15:30:01 -0700
committerJason Evans <jasone@canonware.com>2016-10-11 15:50:05 -0700
commitd419bb09ef6700dde95c74e1f1752f81e5d15d92 (patch)
tree5f9017c8ceb4ac7c54780636ce5ee3140cd2ddf1 /include
parenta14712b4b87df5aa95446f91832ea4846a8f1475 (diff)
downloadjemalloc-d419bb09ef6700dde95c74e1f1752f81e5d15d92.tar.gz
Fix and simplify decay-based purging.
Simplify decay-based purging attempts to only be triggered when the epoch is advanced, rather than every time purgeable memory increases. In a correctly functioning system (not previously the case; see below), this only causes a behavior difference if during subsequent purge attempts the least recently used (LRU) purgeable memory extent is initially too large to be purged, but that memory is reused between attempts and one or more of the next LRU purgeable memory extents are small enough to be purged. In practice this is an arbitrary behavior change that is within the set of acceptable behaviors. As for the purging fix, assure that arena->decay.ndirty is recorded *after* the epoch advance and associated purging occurs. Prior to this fix, it was possible for purging during epoch advance to cause a substantially underrepresentative (arena->ndirty - arena->decay.ndirty), i.e. the number of dirty pages attributed to the current epoch was too low, and a series of unintended purges could result. This fix is also relevant in the context of the simplification described above, but the bug's impact would be limited to over-purging at epoch advances.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/arena.h29
1 files changed, 11 insertions, 18 deletions
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index 048e203..1277d08 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -265,7 +265,7 @@ struct arena_decay_s {
* and/or reused.
*/
ssize_t time;
- /* decay_time / SMOOTHSTEP_NSTEPS. */
+ /* time / SMOOTHSTEP_NSTEPS. */
nstime_t interval;
/*
* Time at which the current decay interval logically started. We do
@@ -275,37 +275,30 @@ struct arena_decay_s {
* merge all relevant activity into the most recently recorded epoch.
*/
nstime_t epoch;
- /* decay_deadline randomness generator. */
+ /* Deadline randomness generator. */
uint64_t jitter_state;
/*
- * Deadline for current epoch. This is the sum of decay_interval and
- * per epoch jitter which is a uniform random variable in
- * [0..decay_interval). Epochs always advance by precise multiples of
- * decay_interval, but we randomize the deadline to reduce the
- * likelihood of arenas purging in lockstep.
+ * Deadline for current epoch. This is the sum of interval and per
+ * epoch jitter which is a uniform random variable in [0..interval).
+ * Epochs always advance by precise multiples of interval, but we
+ * randomize the deadline to reduce the likelihood of arenas purging in
+ * lockstep.
*/
nstime_t deadline;
/*
* Number of dirty pages at beginning of current epoch. During epoch
- * advancement we use the delta between decay_ndirty and ndirty to
- * determine how many dirty pages, if any, were generated, and record
- * the result in decay_backlog.
+ * advancement we use the delta between arena->decay.ndirty and
+ * arena->ndirty to determine how many dirty pages, if any, were
+ * generated.
*/
size_t ndirty;
/*
- * Memoized result of arena_decay_backlog_npages_limit() corresponding
- * to the current contents of decay_backlog, i.e. the limit on how many
- * pages are allowed to exist for the decay epochs.
- */
- size_t backlog_npages_limit;
- /*
* Trailing log of how many unused dirty pages were generated during
* each of the past SMOOTHSTEP_NSTEPS decay epochs, where the last
* element is the most recent epoch. Corresponding epoch times are
- * relative to decay_epoch.
+ * relative to epoch.
*/
size_t backlog[SMOOTHSTEP_NSTEPS];
-
};
struct arena_bin_s {