diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-07-26 11:10:50 +1000 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-07-26 11:11:27 +1000 |
commit | 848e5f5c0bd836781b379f6ade56f16433bd3853 (patch) | |
tree | 6f03ed5cde97aedc762215c14d23ee5305998a2b /src/btree/row_srch.c | |
parent | 8b7110bfacd291cdd4a25420f07b70d3bae7a647 (diff) | |
parent | d8fb874fc40989cb9675e56ca80b3b64e6fa2ee3 (diff) | |
download | mongo-848e5f5c0bd836781b379f6ade56f16433bd3853.tar.gz |
Merge branch 'mongodb-3.4' into mongodb-3.2
Choosing the content of the 3.4 branch, rather than manually
resolving merge conflicts.
Diffstat (limited to 'src/btree/row_srch.c')
-rw-r--r-- | src/btree/row_srch.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/btree/row_srch.c b/src/btree/row_srch.c index 6169a0a810a..4afcd74520f 100644 --- a/src/btree/row_srch.c +++ b/src/btree/row_srch.c @@ -634,14 +634,16 @@ __wt_row_random_leaf(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) WT_INSERT *ins, **start, **stop; WT_INSERT_HEAD *ins_head; WT_PAGE *page; + uint64_t samples; uint32_t choice, entries, i; int level; page = cbt->ref->page; - start = stop = NULL; /* [-Wconditional-uninitialized] */ entries = 0; /* [-Wconditional-uninitialized] */ + __cursor_pos_clear(cbt); + /* If the page has disk-based entries, select from them. */ if (page->pg_row_entries != 0) { cbt->compare = 0; @@ -688,7 +690,7 @@ __wt_row_random_leaf(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) * Step down the skip list levels, selecting a random chunk of the name * space at each level. */ - while (level > 0) { + for (samples = entries; level > 0; samples += entries) { /* * There are (entries) or (entries + 1) chunks of the name space * considered at each level. They are: between start and the 1st @@ -765,6 +767,16 @@ __wt_row_random_leaf(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) cbt->ins_head = ins_head; cbt->compare = 0; + /* + * Random lookups in newly created collections can be slow if a page + * consists of a large skiplist. Schedule the page for eviction if we + * encounter a large skiplist. This worthwhile because applications + * that take a sample often take many samples, so the overhead of + * traversing the skip list each time accumulates to real time. + */ + if (samples > 5000) + __wt_page_evict_soon(page); + return (0); } @@ -784,8 +796,6 @@ __wt_row_random_descent(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) btree = S2BT(session); current = NULL; - __cursor_pos_clear(cbt); - if (0) { restart: /* * Discard the currently held page and restart the search from |