summaryrefslogtreecommitdiff
path: root/src/include/cache.i
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/cache.i')
-rw-r--r--src/include/cache.i52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/include/cache.i b/src/include/cache.i
index ee13eee84c5..8cf7555e716 100644
--- a/src/include/cache.i
+++ b/src/include/cache.i
@@ -28,34 +28,43 @@ __wt_cache_read_gen_incr(WT_SESSION_IMPL *session)
/*
* __wt_cache_read_gen_bump --
- * Get the read generation to keep a page in memory.
+ * Update the page's read generation.
*/
-static inline uint64_t
-__wt_cache_read_gen_bump(WT_SESSION_IMPL *session)
+static inline void
+__wt_cache_read_gen_bump(WT_SESSION_IMPL *session, WT_PAGE *page)
{
+ /* Ignore pages set for forcible eviction. */
+ if (page->read_gen == WT_READGEN_OLDEST)
+ return;
+
+ /* Ignore pages already in the future. */
+ if (page->read_gen > __wt_cache_read_gen(session))
+ return;
+
/*
- * We return read-generations from the future (where "the future" is
- * measured by increments of the global read generation). The reason
- * is because when acquiring a new hazard pointer for a page, we can
- * check its read generation, and if the read generation isn't less
- * than the current global generation, we don't bother updating the
- * page. In other words, the goal is to avoid some number of updates
- * immediately after each update we have to make.
+ * We set read-generations in the future (where "the future" is measured
+ * by increments of the global read generation). The reason is because
+ * when acquiring a new hazard pointer for a page, we can check its read
+ * generation, and if the read generation isn't less than the current
+ * global generation, we don't bother updating the page. In other
+ * words, the goal is to avoid some number of updates immediately after
+ * each update we have to make.
*/
- return (__wt_cache_read_gen(session) + WT_READGEN_STEP);
+ page->read_gen = __wt_cache_read_gen(session) + WT_READGEN_STEP;
}
/*
* __wt_cache_read_gen_new --
* Get the read generation for a new page in memory.
*/
-static inline uint64_t
-__wt_cache_read_gen_new(WT_SESSION_IMPL *session)
+static inline void
+__wt_cache_read_gen_new(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_CACHE *cache;
cache = S2C(session)->cache;
- return (__wt_cache_read_gen(session) + cache->read_gen_oldest) / 2;
+ page->read_gen =
+ (__wt_cache_read_gen(session) + cache->read_gen_oldest) / 2;
}
/*
@@ -119,12 +128,11 @@ __wt_session_can_wait(WT_SESSION_IMPL *session)
return (0);
/*
- * LSM sets the no-eviction flag when holding the LSM tree lock,
- * in that case, or when holding the schema lock, we don't want to
- * highjack the thread for eviction.
+ * LSM sets the no-eviction flag when holding the LSM tree lock, in that
+ * case, or when holding the schema lock, we don't want to highjack the
+ * thread for eviction.
*/
- if (F_ISSET(session,
- WT_SESSION_NO_EVICTION | WT_SESSION_LOCKED_SCHEMA))
+ if (F_ISSET(session, WT_SESSION_NO_EVICTION | WT_SESSION_LOCKED_SCHEMA))
return (0);
return (1);
@@ -224,11 +232,11 @@ __wt_cache_eviction_check(WT_SESSION_IMPL *session, bool busy, bool *didworkp)
return (0);
/*
- * Threads operating on trees that cannot be evicted are ignored,
- * mostly because they're not contributing to the problem.
+ * Threads operating on cache-resident trees are ignored because they're
+ * not contributing to the problem.
*/
btree = S2BT_SAFE(session);
- if (btree != NULL && F_ISSET(btree, WT_BTREE_NO_EVICTION))
+ if (btree != NULL && F_ISSET(btree, WT_BTREE_IN_MEMORY))
return (0);
/* Check if eviction is needed. */