diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-06-05 17:04:55 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2015-06-05 17:04:55 -0400 |
commit | ed9808a617a9fee825b9c33534ad9658693246d4 (patch) | |
tree | 121b0b943e782375df9800c53a6af663b544d909 /src/btree/bt_page.c | |
parent | 93b0419dddefc475f123b7c1226c053dde972a03 (diff) | |
download | mongo-ed9808a617a9fee825b9c33534ad9658693246d4.tar.gz |
Merge __wt_eviction_check, __wt_cache_full_check and __wt_cache_wait
into __cache_check (a simple cache-size helper function), and a worker
function, __wt_cache_full_check.
Add a new parameter to __wt_cache_full_check, set if the caller is
"busy". It's set for callers stalling for some reason (for example,
waiting on a disk read). If the caller is busy, we only use it for a
single page eviction before returning it to its previous task.
Change the page-in function to check on the cache when a thread is
about to stall, and evict a page instead of sleeping.
The way this used to work was a thread would start evicting pages if the
cache was > 95% full or there were eviction target values we wanted to
reach, but would evict a single page and quit evicting as soon as the
cache was < 100% full, regardless of eviction target values. Now we
continue working until we both reach < 95% and the eviction target
values, that is, we'll throttle threads unless they're currently "busy".
Reference WT-1744.
Diffstat (limited to 'src/btree/bt_page.c')
-rw-r--r-- | src/btree/bt_page.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/btree/bt_page.c b/src/btree/bt_page.c index 9c63d06907a..993cf64c958 100644 --- a/src/btree/bt_page.c +++ b/src/btree/bt_page.c @@ -72,7 +72,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags WT_DECL_RET; WT_PAGE *page; u_int sleep_cnt, wait_cnt; - int busy, force_attempts, oldgen; + int busy, cache_work, force_attempts, oldgen; for (force_attempts = oldgen = 0, wait_cnt = 0;;) { switch (ref->state) { @@ -85,7 +85,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags * The page isn't in memory, attempt to read it. * Make sure there is space in the cache. */ - WT_RET(__wt_cache_full_check(session)); + WT_RET(__wt_cache_full_check(session, 1, NULL)); WT_RET(__wt_cache_read(session, ref)); oldgen = LF_ISSET(WT_READ_WONT_NEED) || F_ISSET(session, WT_SESSION_NO_CACHE); @@ -207,10 +207,19 @@ skip_evict: if (0) { stall: wait_cnt += 1000; } - sleep_cnt = WT_MIN(wait_cnt, 10000); - wait_cnt *= 2; - WT_STAT_FAST_CONN_INCRV(session, page_sleep, sleep_cnt); - __wt_sleep(0, sleep_cnt); + + /* + * If stalling, check if the cache needs help. If we do + * work for the cache, substitute that for a sleep. + */ + WT_RET(__wt_cache_full_check(session, 1, &cache_work)); + if (!cache_work) { + sleep_cnt = WT_MIN(wait_cnt, 10000); + wait_cnt *= 2; + WT_STAT_FAST_CONN_INCRV( + session, page_sleep, sleep_cnt); + __wt_sleep(0, sleep_cnt); + } } } } |