summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-12-19 15:44:15 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2014-12-19 15:44:15 +1100
commit0d21e437917bc7cf08393852a3074957431ea30e (patch)
tree2ca6efed8ea7835ad9dc2bfb3ca7ff5be405d759
parent9bb5bbacb55922985283844c1901ddd6c4f97e72 (diff)
downloadmongo-0d21e437917bc7cf08393852a3074957431ea30e.tar.gz
Use the eviction server to write pages with READGEN_OLDEST set.
Even before the eviction trigger has been reached. This should mean that we clear those pages out of cache earlier, and hopefully will save application threads from doing the evictions (at least sometimes).
-rw-r--r--src/btree/bt_curnext.c2
-rw-r--r--src/btree/bt_curprev.c2
-rw-r--r--src/btree/bt_page.c4
-rw-r--r--src/evict/evict_lru.c16
-rw-r--r--src/include/btree.i6
-rw-r--r--src/include/cache.h4
-rw-r--r--src/include/cursor.i2
7 files changed, 29 insertions, 7 deletions
diff --git a/src/btree/bt_curnext.c b/src/btree/bt_curnext.c
index 9cd7f0241fc..31d272dc09c 100644
--- a/src/btree/bt_curnext.c
+++ b/src/btree/bt_curnext.c
@@ -483,7 +483,7 @@ __wt_btcur_next(WT_CURSOR_BTREE *cbt, int truncating)
if (page != NULL &&
(cbt->page_deleted_count > WT_BTREE_DELETE_THRESHOLD ||
(newpage && cbt->page_deleted_count > 0)))
- __wt_page_evict_soon(page);
+ __wt_page_evict_soon(session, page);
cbt->page_deleted_count = 0;
WT_ERR(__wt_tree_walk(session, &cbt->ref, flags));
diff --git a/src/btree/bt_curprev.c b/src/btree/bt_curprev.c
index 851b01d3732..e749a5b5b51 100644
--- a/src/btree/bt_curprev.c
+++ b/src/btree/bt_curprev.c
@@ -570,7 +570,7 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, int truncating)
if (page != NULL &&
(cbt->page_deleted_count > WT_BTREE_DELETE_THRESHOLD ||
(newpage && cbt->page_deleted_count > 0)))
- __wt_page_evict_soon(page);
+ __wt_page_evict_soon(session, page);
cbt->page_deleted_count = 0;
WT_ERR(__wt_tree_walk(session, &cbt->ref, flags));
diff --git a/src/btree/bt_page.c b/src/btree/bt_page.c
index 799f0cca3ee..3c92cba709c 100644
--- a/src/btree/bt_page.c
+++ b/src/btree/bt_page.c
@@ -48,7 +48,7 @@ __evict_force_check(WT_SESSION_IMPL *session, WT_PAGE *page)
return (0);
/* Trigger eviction on the next page release. */
- __wt_page_evict_soon(page);
+ __wt_page_evict_soon(session, page);
return (1);
}
@@ -138,7 +138,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags
* Otherwise, update the page's read generation.
*/
if (oldgen && page->read_gen == WT_READGEN_NOTSET)
- __wt_page_evict_soon(page);
+ __wt_page_evict_soon(session, page);
else if (!LF_ISSET(WT_READ_NO_GEN) &&
page->read_gen < __wt_cache_read_gen(session))
page->read_gen =
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index dbf3a71f222..2ff7cec9ef6 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -407,6 +407,14 @@ __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_EARLY_CANDIDATES)) {
+ /*
+ * Trickle out pages with oldest generation set regardless of
+ * whether we have reached the eviction trigger.
+ */
+ LF_SET(WT_EVICT_PASS_TRICKLE);
+ F_CLR(cache, WT_EVICT_EARLY_CANDIDATES);
+ }
if (F_ISSET(cache, WT_EVICT_STUCK))
LF_SET(WT_EVICT_PASS_AGGRESSIVE);
@@ -1076,6 +1084,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_TRICKLE) &&
+ 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/include/btree.i b/src/include/btree.i
index 6c42155fefb..d2198a1462d 100644
--- a/src/include/btree.i
+++ b/src/include/btree.i
@@ -227,9 +227,13 @@ __wt_cache_bytes_inuse(WT_CACHE *cache)
* Set a page to be evicted as soon as possible.
*/
static inline void
-__wt_page_evict_soon(WT_PAGE *page)
+__wt_page_evict_soon(WT_SESSION_IMPL *session, WT_PAGE *page)
{
page->read_gen = WT_READGEN_OLDEST;
+ if (!F_ISSET(S2C(session)->cache, WT_EVICT_EARLY_CANDIDATES)) {
+ F_SET(S2C(session)->cache, WT_EVICT_EARLY_CANDIDATES);
+ (void)__wt_evict_server_wake(session);
+ }
}
/*
diff --git a/src/include/cache.h b/src/include/cache.h
index a6425e97837..a28204c5582 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_TRICKLE 0x08
/*
* WT_EVICT_ENTRY --
@@ -113,7 +114,8 @@ struct __wt_cache {
#define WT_CACHE_POOL_RUN 0x02 /* Cache pool thread running */
#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_EARLY_CANDIDATES 0x10 /* Evict before trigger */
+#define WT_EVICT_STUCK 0x20 /* Eviction server is stuck */
uint32_t flags;
};
diff --git a/src/include/cursor.i b/src/include/cursor.i
index 737ac8dcdba..d56f65db0a6 100644
--- a/src/include/cursor.i
+++ b/src/include/cursor.i
@@ -122,7 +122,7 @@ __curfile_leave(WT_CURSOR_BTREE *cbt)
*/
if (cbt->ref != NULL &&
cbt->page_deleted_count > WT_BTREE_DELETE_THRESHOLD)
- __wt_page_evict_soon(cbt->ref->page);
+ __wt_page_evict_soon(session, cbt->ref->page);
cbt->page_deleted_count = 0;
/*