diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-27 12:50:23 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2015-01-27 12:50:23 +1100 |
commit | f9b1b2539dc6b28116b2b731072bf813075ec12b (patch) | |
tree | 12b7bf95e0ff6fc5ad28cd9cfa7455943b765721 /src/include/cache.i | |
parent | 695bae9649a3d24ad3898bf90291d09d3050db75 (diff) | |
parent | 4d4b86e05e49f4f1138a30e12b819959cb219a4b (diff) | |
download | mongo-f9b1b2539dc6b28116b2b731072bf813075ec12b.tar.gz |
Merge branch 'develop' into memory-allocation
Conflicts:
src/include/wiredtiger.in
Diffstat (limited to 'src/include/cache.i')
-rw-r--r-- | src/include/cache.i | 75 |
1 files changed, 7 insertions, 68 deletions
diff --git a/src/include/cache.i b/src/include/cache.i index 877818a618a..0295451ef11 100644 --- a/src/include/cache.i +++ b/src/include/cache.i @@ -141,10 +141,7 @@ static inline int __wt_cache_full_check(WT_SESSION_IMPL *session) { WT_BTREE *btree; - WT_DECL_RET; - WT_TXN_GLOBAL *txn_global; - WT_TXN_STATE *txn_state; - int busy, count, full; + int full; /* * LSM sets the no-cache-check flag when holding the LSM tree lock, in @@ -167,73 +164,15 @@ __wt_cache_full_check(WT_SESSION_IMPL *session) * Only wake the eviction server the first time through here (if the * cache is too full). * - * If the cache is less than 95% full, no work to be done. + * If the cache is less than 95% full, no work to be done. If we are + * at the API boundary and the cache is more than 95% full, try to + * evict at least one page before we start an operation. This helps + * with some eviction-dominated workloads. */ WT_RET(__wt_eviction_check(session, &full, 1)); if (full < 95) return (0); - /* - * If we are at the API boundary and the cache is more than 95% full, - * try to evict at least one page before we start an operation. This - * helps with some eviction-dominated workloads. - * - * If the current transaction is keeping the oldest ID pinned, it is in - * the middle of an operation. This may prevent the oldest ID from - * moving forward, leading to deadlock, so only evict what we can. - * Otherwise, we are at a transaction boundary and we can work harder - * to make sure there is free space in the cache. - */ - txn_global = &S2C(session)->txn_global; - txn_state = &txn_global->states[session->id]; - busy = txn_state->id != WT_TXN_NONE || - session->nhazard > 0 || - (txn_state->snap_min != WT_TXN_NONE && - txn_global->current != txn_global->oldest_id); - if (busy && full < 100) - return (0); - count = busy ? 1 : 10; - - for (;;) { - switch (ret = __wt_evict_lru_page(session, 1)) { - case 0: - if (--count == 0) - return (0); - break; - case EBUSY: - continue; - case WT_NOTFOUND: - break; - default: - return (ret); - } - - WT_RET(__wt_eviction_check(session, &full, 0)); - if (full < 100) - return (0); - else if (ret == 0) - continue; - - /* - * The cache is still full and no pages were found in the queue - * to evict. If this transaction is the one holding back the - * oldest ID, we can't wait forever. We'll block next time we - * are not busy. - */ - if (busy) { - __wt_txn_update_oldest(session); - if (txn_state->id == txn_global->oldest_id || - txn_state->snap_min == txn_global->oldest_id) - return (0); - } - - /* Wait for the queue to re-populate before trying again. */ - WT_RET(__wt_cond_wait(session, - S2C(session)->cache->evict_waiter_cond, 100000)); - - /* Check if things have changed so that we are busy. */ - if (!busy && txn_state->snap_min != WT_TXN_NONE && - txn_global->current != txn_global->oldest_id) - busy = count = 1; - } + return (__wt_cache_wait(session, full)); } + |