diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2015-06-09 13:44:30 -0400 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-06-29 14:04:09 +1000 |
commit | 28c395baf4be3cdceb398fea80eb8f7b7513759c (patch) | |
tree | 74c2ec860d4b991ec2e7771e5c1f47a8900dbfe3 | |
parent | 597dddd70578fe4b6e6533fba1a76899f9e4f99f (diff) | |
download | mongo-28c395baf4be3cdceb398fea80eb8f7b7513759c.tar.gz |
SERVER-18829 Have pages start in the middle of the LRU queue for eviction.
(cherry picked from commit d57dc26729bbc59c5bc3928aa90bb2ac3cd15d6d)
-rw-r--r-- | src/btree/bt_page.c | 2 | ||||
-rw-r--r-- | src/evict/evict_lru.c | 28 | ||||
-rw-r--r-- | src/include/cache.h | 2 | ||||
-rw-r--r-- | src/include/cache.i | 19 |
4 files changed, 35 insertions, 16 deletions
diff --git a/src/btree/bt_page.c b/src/btree/bt_page.c index 0b93cc981d7..a653a91a25e 100644 --- a/src/btree/bt_page.c +++ b/src/btree/bt_page.c @@ -168,7 +168,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags page->read_gen != WT_READGEN_OLDEST && page->read_gen < __wt_cache_read_gen(session)) page->read_gen = - __wt_cache_read_gen_set(session); + __wt_cache_read_gen_bump(session); return (0); WT_ILLEGAL_VALUE(session); diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index a3bab5457f6..a5f57e29d52 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -493,6 +493,14 @@ __evict_pass(WT_SESSION_IMPL *session) session, cache->evict_waiter_cond)); } + /* + * Increment the shared read generation. We do this + * occasionally even if eviction is not currently required, so + * that pages have some relative read generation when the + * eviction server does need to do some work. + */ + __wt_cache_read_gen_incr(session); + WT_RET(__evict_has_work(session, &flags)); if (flags == 0) break; @@ -838,6 +846,9 @@ __evict_lru_walk(WT_SESSION_IMPL *session, uint32_t flags) WT_ASSERT(session, cache->evict[0].ref != NULL); + /* Track the oldest read generation we have in the queue. */ + cache->read_gen_oldest = cache->evict[0].ref->page->read_gen; + if (LF_ISSET(WT_EVICT_PASS_AGGRESSIVE | WT_EVICT_PASS_WOULD_BLOCK)) /* * Take all candidates if we only gathered pages with an oldest @@ -933,9 +944,6 @@ __evict_walk(WT_SESSION_IMPL *session, uint32_t flags) incr = dhandle_locked = 0; retries = 0; - /* Increment the shared read generation. */ - __wt_cache_read_gen_incr(session); - /* * Update the oldest ID: we use it to decide whether pages are * candidates for eviction. Without this, if all threads are blocked @@ -1222,15 +1230,11 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp, uint32_t flags) continue; /* - * If this page has never been considered for eviction, - * set its read generation to a little bit in the - * future and move on, give readers a chance to start - * updating the read generation. + * If this page has never been considered for eviction, set its + * read generation to somewhere in the middle of the LRU list. */ - if (page->read_gen == WT_READGEN_NOTSET) { - page->read_gen = __wt_cache_read_gen_set(session); - continue; - } + if (page->read_gen == WT_READGEN_NOTSET) + page->read_gen = __wt_cache_read_gen_new(session); fast: /* If the page can't be evicted, give up. */ if (!__wt_page_can_evict(session, page, 1)) @@ -1424,7 +1428,7 @@ __wt_evict_lru_page(WT_SESSION_IMPL *session, int is_server) */ page = ref->page; if (page->read_gen != WT_READGEN_OLDEST) - page->read_gen = __wt_cache_read_gen_set(session); + page->read_gen = __wt_cache_read_gen_bump(session); /* * If we are evicting in a dead tree, don't write dirty pages. diff --git a/src/include/cache.h b/src/include/cache.h index 11f631416af..58b7b4dbddb 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -71,6 +71,8 @@ struct __wt_cache { * Read information. */ uint64_t read_gen; /* Page read generation (LRU) */ + uint64_t read_gen_oldest; /* The oldest read generation that + eviction knows about */ /* * Eviction thread information. diff --git a/src/include/cache.i b/src/include/cache.i index f952f1bf698..d84069c43fb 100644 --- a/src/include/cache.i +++ b/src/include/cache.i @@ -27,11 +27,11 @@ __wt_cache_read_gen_incr(WT_SESSION_IMPL *session) } /* - * __wt_cache_read_gen_set -- - * Get the read generation to store in a page. + * __wt_cache_read_gen_bump -- + * Get the read generation to keep a page in memory. */ static inline uint64_t -__wt_cache_read_gen_set(WT_SESSION_IMPL *session) +__wt_cache_read_gen_bump(WT_SESSION_IMPL *session) { /* * We return read-generations from the future (where "the future" is @@ -46,6 +46,19 @@ __wt_cache_read_gen_set(WT_SESSION_IMPL *session) } /* + * __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) +{ + WT_CACHE *cache; + + cache = S2C(session)->cache; + return (__wt_cache_read_gen(session) + cache->read_gen_oldest) / 2; +} + +/* * __wt_cache_pages_inuse -- * Return the number of pages in use. */ |