summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Cahill <mjc@wiredtiger.com>2014-12-22 16:04:34 +1100
committerMichael Cahill <mjc@wiredtiger.com>2014-12-22 16:04:34 +1100
commit8839103c5fd2dbbfdfad7bde45755be51d549651 (patch)
treecad389a036f225c2847e4f19f43ffa6b0e2fe2ff /src
parentfbb96d94cdba9a28f5c5d737ce6c96543f3289f4 (diff)
parent6a98af60ca3c423851c0a4c39edb0dfa7d741291 (diff)
downloadmongo-8839103c5fd2dbbfdfad7bde45755be51d549651.tar.gz
Merge pull request #1500 from wiredtiger/evict-trickle
Use the eviction server to write pages with READGEN_OLDEST set.
Diffstat (limited to 'src')
-rw-r--r--src/evict/evict_lru.c17
-rw-r--r--src/evict/evict_page.c18
-rw-r--r--src/include/cache.h3
3 files changed, 32 insertions, 6 deletions
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index dbf3a71f222..69fa1f85c93 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -407,6 +407,15 @@ __evict_has_work(WT_SESSION_IMPL *session, uint32_t *flagsp)
(cache->eviction_dirty_target * bytes_max) / 100)
/* Ignore clean pages unless the cache is too large */
LF_SET(WT_EVICT_PASS_DIRTY);
+ else if (F_ISSET(cache, WT_EVICT_WOULD_BLOCK)) {
+ /*
+ * Evict pages with oldest generation (which would otherwise
+ * block application threads) set regardless of whether we have
+ * reached the eviction trigger.
+ */
+ LF_SET(WT_EVICT_PASS_WOULD_BLOCK);
+ F_CLR(cache, WT_EVICT_WOULD_BLOCK);
+ }
if (F_ISSET(cache, WT_EVICT_STUCK))
LF_SET(WT_EVICT_PASS_AGGRESSIVE);
@@ -1076,6 +1085,14 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp, uint32_t flags)
if (F_ISSET_ATOMIC(page, WT_PAGE_EVICT_LRU))
continue;
+ /*
+ * If we are only trickling out pages marked for definite
+ * eviction, skip anything that isn't marked.
+ */
+ if (LF_ISSET(WT_EVICT_PASS_WOULD_BLOCK) &&
+ page->read_gen != WT_READGEN_OLDEST)
+ continue;
+
/* Limit internal pages to 50% unless we get aggressive. */
if ((page->type == WT_PAGE_COL_INT ||
page->type == WT_PAGE_ROW_INT) &&
diff --git a/src/evict/evict_page.c b/src/evict/evict_page.c
index f7cbb55dbe4..4e96898fd92 100644
--- a/src/evict/evict_page.c
+++ b/src/evict/evict_page.c
@@ -24,9 +24,10 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, int exclusive)
WT_PAGE *page;
WT_PAGE_MODIFY *mod;
WT_TXN_STATE *txn_state;
- int inmem_split, istree;
+ int forced_eviction, inmem_split, istree;
page = ref->page;
+ forced_eviction = (page->read_gen == WT_READGEN_OLDEST);
inmem_split = istree = 0;
WT_RET(__wt_verbose(session, WT_VERB_EVICT,
@@ -116,6 +117,12 @@ done: session->excl_next = 0;
if (txn_state != NULL)
txn_state->snap_min = WT_TXN_NONE;
+ if ((inmem_split || (forced_eviction && ret == EBUSY)) &&
+ !F_ISSET(S2C(session)->cache, WT_EVICT_WOULD_BLOCK)) {
+ F_SET(S2C(session)->cache, WT_EVICT_WOULD_BLOCK);
+ WT_TRET(__wt_evict_server_wake(session));
+ }
+
return (ret);
}
@@ -308,7 +315,6 @@ __evict_review(WT_SESSION_IMPL *session, WT_REF *ref,
uint32_t flags;
btree = S2BT(session);
- page = ref->page;
/*
* Get exclusive access to the page if our caller doesn't have the tree
@@ -327,6 +333,10 @@ __evict_review(WT_SESSION_IMPL *session, WT_REF *ref,
__wt_evict_list_clear_page(session, ref);
}
+ /* Now that we have exclusive access, review the page. */
+ page = ref->page;
+ mod = page->modify;
+
/*
* Recurse through the page's subtree: this happens first because we
* have to write pages in depth-first order, otherwise we'll dirty
@@ -338,8 +348,6 @@ __evict_review(WT_SESSION_IMPL *session, WT_REF *ref,
WT_RET(ret);
}
- mod = page->modify;
-
/*
* If the tree was deepened, there's a requirement that newly created
* internal pages not be evicted until all threads are known to have
@@ -449,7 +457,7 @@ __evict_review(WT_SESSION_IMPL *session, WT_REF *ref,
if (exclusive)
LF_SET(WT_SKIP_UPDATE_ERR);
else if (top && !WT_PAGE_IS_INTERNAL(page) &&
- page->memory_footprint > 10 * btree->maxleafpage)
+ page->read_gen == WT_READGEN_OLDEST)
LF_SET(WT_SKIP_UPDATE_RESTORE);
WT_RET(__wt_reconcile(session, ref, NULL, flags));
WT_ASSERT(session,
diff --git a/src/include/cache.h b/src/include/cache.h
index a6425e97837..cf688b3993f 100644
--- a/src/include/cache.h
+++ b/src/include/cache.h
@@ -19,6 +19,7 @@
#define WT_EVICT_PASS_AGGRESSIVE 0x01
#define WT_EVICT_PASS_ALL 0x02
#define WT_EVICT_PASS_DIRTY 0x04
+#define WT_EVICT_PASS_WOULD_BLOCK 0x08
/*
* WT_EVICT_ENTRY --
@@ -33,7 +34,6 @@ struct __wt_evict_entry {
* WT_EVICT_WORKER --
* Encapsulation of an eviction worker thread.
*/
-
struct __wt_evict_worker {
WT_SESSION_IMPL *session;
u_int id;
@@ -114,6 +114,7 @@ struct __wt_cache {
#define WT_EVICT_ACTIVE 0x04 /* Eviction server is active */
#define WT_EVICT_CLEAR_WALKS 0x08 /* Clear eviction walks */
#define WT_EVICT_STUCK 0x10 /* Eviction server is stuck */
+#define WT_EVICT_WOULD_BLOCK 0x20 /* Pages that would block apps */
uint32_t flags;
};