diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-10-10 13:29:56 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-10-10 13:29:56 +1100 |
commit | a86745496427ee7977bb7d2dbdb86ba8ee6b2c0a (patch) | |
tree | 06dd5cb7c5c8bd7367a595c55132361c92ad638d | |
parent | cdc0b2462fe39d8d2d62f58bbe7de3578e7d508a (diff) | |
download | mongo-a86745496427ee7977bb7d2dbdb86ba8ee6b2c0a.tar.gz |
Walk a constant number of pages for LRU.
-rw-r--r-- | src/btree/bt_evict.c | 12 | ||||
-rw-r--r-- | 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. |