From a86745496427ee7977bb7d2dbdb86ba8ee6b2c0a Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Wed, 10 Oct 2012 13:29:56 +1100 Subject: Walk a constant number of pages for LRU. --- src/btree/bt_evict.c | 12 ++++++++---- src/include/cache.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/btree/bt_evict.c b/src/btree/bt_evict.c index 064e1b096f6..64d11d9ef7a 100644 --- a/src/btree/bt_evict.c +++ b/src/btree/bt_evict.c @@ -719,7 +719,7 @@ __evict_walk(WT_SESSION_IMPL *session) WT_CACHE *cache; WT_CONNECTION_IMPL *conn; WT_DECL_RET; - u_int elem, i; + u_int elem, file_count, i; conn = S2C(session); cache = S2C(session)->cache; @@ -729,8 +729,7 @@ __evict_walk(WT_SESSION_IMPL *session) * get some pages from each underlying file. In practice, a realloc * is rarely needed, so it is worth avoiding the LRU lock. */ - elem = WT_EVICT_WALK_BASE + - (conn->open_btree_count * WT_EVICT_WALK_PER_TABLE); + elem = WT_EVICT_WALK_BASE + 2 * WT_EVICT_GROUP; if (elem > cache->evict_entries) { __wt_spin_lock(session, &cache->evict_lock); /* Save the offset of the eviction point. */ @@ -749,7 +748,11 @@ __evict_walk(WT_SESSION_IMPL *session) * servicing eviction requests. */ i = WT_EVICT_WALK_BASE; + file_count = 0; TAILQ_FOREACH(btree, &conn->btqh, q) { + if (file_count++ < cache->evict_file_next) + continue; + /* * Skip files that aren't open or don't have a root page. * @@ -770,9 +773,10 @@ __evict_walk(WT_SESSION_IMPL *session) ret = __evict_walk_file(session, &i); WT_CLEAR_BTREE_IN_SESSION(session); - if (ret != 0) + if (ret != 0 || i == cache->evict_entries) break; } + cache->evict_file_next = (btree == NULL) ? 0 : file_count; if (0) { err: __wt_spin_unlock(session, &cache->evict_lock); diff --git a/src/include/cache.h b/src/include/cache.h index 2fc7e0fedd3..73dd5ab1c31 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -52,6 +52,7 @@ struct __wt_cache { WT_EVICT_ENTRY *evict_current; /* LRU current page to be evicted */ size_t evict_allocated; /* LRU list bytes allocated */ uint32_t evict_entries; /* LRU list eviction slots */ + u_int evict_file_next; /* LRU: next file to search */ /* * Forced-page eviction request information. -- cgit v1.2.1