From 8d27ecbc5c4fd65d8b49810dd06d5bb424a63c3b Mon Sep 17 00:00:00 2001 From: Alex Gorrod Date: Fri, 4 Dec 2015 16:22:36 +1100 Subject: WT-2260 Avoid adding internal pages to the eviction queue. We added code to make eviction fairer when there are lots of files open, but it had the effect that when there are only a few files open eviction could add lots of internal pages to the eviction queue, since it focused on a small area of the tree. --- src/evict/evict_lru.c | 11 ++++++++++- src/include/cache.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index 306362de57f..a0900cf23ba 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -466,6 +466,15 @@ __evict_update_work(WT_SESSION_IMPL *session) if (!F_ISSET(conn, WT_CONN_EVICTION_RUN)) return (false); + /* + * Setup the number of refs to consider in each handle, depending + * on how many handles are open. We want to consider less candidates + * from each file as more files are open. Handle the case where there + * are no files open by adding 1. + */ + cache->evict_max_refs_per_file = + WT_MAX(100, WT_MILLION / (conn->open_file_count + 1)); + /* * Page eviction overrides the dirty target and other types of eviction, * that is, we don't care where we are with respect to the dirty target @@ -1202,7 +1211,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) evict < end && !enough && (ret == 0 || ret == WT_NOTFOUND); ret = __wt_tree_walk( session, &btree->evict_ref, &pages_walked, walk_flags)) { - enough = pages_walked > WT_EVICT_MAX_PER_FILE; + enough = pages_walked > cache->evict_max_refs_per_file; if ((ref = btree->evict_ref) == NULL) { if (++restarts == 2 || enough) break; diff --git a/src/include/cache.h b/src/include/cache.h index d8a3829863f..a0440f23a00 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -14,7 +14,6 @@ pages by this many increments of the read generation. */ #define WT_EVICT_WALK_PER_FILE 10 /* Pages to queue per file */ -#define WT_EVICT_MAX_PER_FILE 100 /* Max pages to visit per file */ #define WT_EVICT_WALK_BASE 300 /* Pages tracked across file visits */ #define WT_EVICT_WALK_INCR 100 /* Pages added each walk */ @@ -107,6 +106,7 @@ struct __wt_cache { uint32_t evict_slots; /* LRU list eviction slots */ WT_DATA_HANDLE *evict_file_next; /* LRU next file to search */ + uint32_t evict_max_refs_per_file;/* LRU pages per file per pass */ /* * Cache pool information. -- cgit v1.2.1