summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2017-07-10 23:33:31 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-09-07 08:52:53 +1000
commit31af5d70a87cf1d99c7275bc8bc01d29e2cb0d2a (patch)
treeea27c47def1002f9d85e516fa8d5caf16d8695c9
parent3579adf6c8b96d26898af9fe3cc5eb9677f75632 (diff)
downloadmongodb-3.4.9.tar.gz
WT-3329 Visit trees using a tiny fraction of cache. (#3442)mongodb-3.4.9
For workloads where no tree takes up a large enough fraction of cache, we were using a randomized approach to deciding when eviction should visit trees. That led to slow performance for workloads with uniform updates over thousands of trees. (cherry picked from commit 2f1ec98512010f6c92bf27a41180e3c8704b54c8) Signed-off-by: Alex Gorrod <alexander.gorrod@mongodb.com>
-rw-r--r--src/evict/evict_lru.c26
-rw-r--r--src/include/extern.h1
-rw-r--r--src/support/rand.c12
3 files changed, 8 insertions, 31 deletions
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index cc3c5a5c824..fdf68841b85 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -1647,26 +1647,16 @@ __evict_walk_file(WT_SESSION_IMPL *session,
QUEUE_FILLS_PER_PASS;
/*
- * Randomly walk trees with a small fraction of the cache in case there
- * are so many trees that none of them use enough of the cache to be
- * allocated slots.
- *
- * The chance of walking a tree is equal to the chance that a random
- * byte in cache belongs to the tree, weighted by how many times we
- * want to fill queues during a pass through all the trees in cache.
+ * Walk trees with a small fraction of the cache in case there are so
+ * many trees that none of them use enough of the cache to be allocated
+ * slots. Only skip a tree if it has no bytes of interest.
*/
if (target_pages == 0) {
- if (F_ISSET(cache, WT_CACHE_EVICT_CLEAN)) {
- btree_inuse = __wt_btree_bytes_evictable(session);
- cache_inuse = __wt_cache_bytes_inuse(cache);
- } else {
- btree_inuse = __wt_btree_dirty_leaf_inuse(session);
- cache_inuse = __wt_cache_dirty_leaf_inuse(cache);
- }
- if (btree_inuse == 0 || cache_inuse == 0)
- return (0);
- if (__wt_random64(&session->rnd) % cache_inuse >
- btree_inuse * QUEUE_FILLS_PER_PASS)
+ btree_inuse = F_ISSET(cache, WT_CACHE_EVICT_CLEAN) ?
+ __wt_btree_bytes_evictable(session) :
+ __wt_btree_dirty_leaf_inuse(session);
+
+ if (btree_inuse == 0)
return (0);
}
diff --git a/src/include/extern.h b/src/include/extern.h
index dfd2d03707f..12233c0247a 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -692,7 +692,6 @@ extern uint32_t __wt_rduppo2(uint32_t n, uint32_t po2);
extern void __wt_random_init(WT_RAND_STATE volatile *rnd_state) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default")));
extern void __wt_random_init_seed( WT_SESSION_IMPL *session, WT_RAND_STATE volatile *rnd_state) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default")));
extern uint32_t __wt_random(WT_RAND_STATE volatile *rnd_state) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default")));
-extern uint64_t __wt_random64(WT_RAND_STATE volatile *rnd_state) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default")));
extern int __wt_buf_grow_worker(WT_SESSION_IMPL *session, WT_ITEM *buf, size_t size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_buf_fmt(WT_SESSION_IMPL *session, WT_ITEM *buf, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_buf_catfmt(WT_SESSION_IMPL *session, WT_ITEM *buf, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
diff --git a/src/support/rand.c b/src/support/rand.c
index 4fae43edc8e..a5b229b9abc 100644
--- a/src/support/rand.c
+++ b/src/support/rand.c
@@ -120,15 +120,3 @@ __wt_random(WT_RAND_STATE volatile * rnd_state)
return ((z << 16) + (w & 65535));
}
-
-/*
- * __wt_random64 --
- * Return a 64-bit pseudo-random number.
- */
-uint64_t
-__wt_random64(WT_RAND_STATE volatile * rnd_state)
- WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
-{
- return (((uint64_t)__wt_random(rnd_state) << 32) +
- __wt_random(rnd_state));
-}