summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hows <howsdav@gmail.com>2016-11-11 23:04:25 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2016-11-11 23:04:25 +1100
commitdc2d7aa2d1f5756bdf522168fc056824543eb067 (patch)
tree3fe37e5e9c142c7040c7f0daf661a2b363d6a57b
parent8b05389ae90d593bc2376c8c7f0fa72830ce5fbf (diff)
downloadmongo-dc2d7aa2d1f5756bdf522168fc056824543eb067.tar.gz
WT-3012 Don't track the LSM Primary as part of dirty bytes in cache (#3136)
-rw-r--r--src/include/btree.h19
-rw-r--r--src/include/btree.i54
-rw-r--r--src/lsm/lsm_cursor.c2
-rw-r--r--src/lsm/lsm_work_unit.c2
4 files changed, 61 insertions, 16 deletions
diff --git a/src/include/btree.h b/src/include/btree.h
index 713d46ae85f..0e0f7b4c40a 100644
--- a/src/include/btree.h
+++ b/src/include/btree.h
@@ -158,15 +158,16 @@ struct __wt_btree {
#define WT_BTREE_IGNORE_CACHE 0x000200 /* Cache-resident object */
#define WT_BTREE_IN_MEMORY 0x000400 /* Cache-resident object */
#define WT_BTREE_LOOKASIDE 0x000800 /* Look-aside table */
-#define WT_BTREE_NO_CHECKPOINT 0x001000 /* Disable checkpoints */
-#define WT_BTREE_NO_EVICTION 0x002000 /* Disable eviction */
-#define WT_BTREE_NO_LOGGING 0x004000 /* Disable logging */
-#define WT_BTREE_NO_RECONCILE 0x008000 /* Allow splits, even with no evict */
-#define WT_BTREE_REBALANCE 0x010000 /* Handle is for rebalance */
-#define WT_BTREE_SALVAGE 0x020000 /* Handle is for salvage */
-#define WT_BTREE_SKIP_CKPT 0x040000 /* Handle skipped checkpoint */
-#define WT_BTREE_UPGRADE 0x080000 /* Handle is for upgrade */
-#define WT_BTREE_VERIFY 0x100000 /* Handle is for verify */
+#define WT_BTREE_LSM_PRIMARY 0x001000 /* Handle is current LSM primary */
+#define WT_BTREE_NO_CHECKPOINT 0x002000 /* Disable checkpoints */
+#define WT_BTREE_NO_EVICTION 0x004000 /* Disable eviction */
+#define WT_BTREE_NO_LOGGING 0x008000 /* Disable logging */
+#define WT_BTREE_NO_RECONCILE 0x010000 /* Allow splits, even with no evict */
+#define WT_BTREE_REBALANCE 0x020000 /* Handle is for rebalance */
+#define WT_BTREE_SALVAGE 0x040000 /* Handle is for salvage */
+#define WT_BTREE_SKIP_CKPT 0x080000 /* Handle skipped checkpoint */
+#define WT_BTREE_UPGRADE 0x100000 /* Handle is for upgrade */
+#define WT_BTREE_VERIFY 0x200000 /* Handle is for verify */
uint32_t flags;
};
diff --git a/src/include/btree.i b/src/include/btree.i
index e48189d50ea..6fe2a101f48 100644
--- a/src/include/btree.i
+++ b/src/include/btree.i
@@ -107,7 +107,7 @@ __wt_cache_page_inmem_incr(WT_SESSION_IMPL *session, WT_PAGE *page, size_t size)
(void)__wt_atomic_addsize(&page->modify->bytes_dirty, size);
if (WT_PAGE_IS_INTERNAL(page))
(void)__wt_atomic_add64(&cache->bytes_dirty_intl, size);
- else {
+ else if (!F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) {
(void)__wt_atomic_add64(&cache->bytes_dirty_leaf, size);
(void)__wt_atomic_add64(&btree->bytes_dirty_leaf, size);
}
@@ -241,7 +241,7 @@ __wt_cache_page_byte_dirty_decr(
if (WT_PAGE_IS_INTERNAL(page))
__wt_cache_decr_check_uint64(session, &cache->bytes_dirty_intl,
decr, "WT_CACHE.bytes_dirty_intl");
- else {
+ else if (!F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) {
__wt_cache_decr_check_uint64(session, &btree->bytes_dirty_leaf,
decr, "WT_BTREE.bytes_dirty_leaf");
__wt_cache_decr_check_uint64(session, &cache->bytes_dirty_leaf,
@@ -300,8 +300,10 @@ __wt_cache_dirty_incr(WT_SESSION_IMPL *session, WT_PAGE *page)
(void)__wt_atomic_add64(&cache->bytes_dirty_intl, size);
(void)__wt_atomic_add64(&cache->pages_dirty_intl, 1);
} else {
- (void)__wt_atomic_add64(&btree->bytes_dirty_leaf, size);
- (void)__wt_atomic_add64(&cache->bytes_dirty_leaf, size);
+ if (!F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) {
+ (void)__wt_atomic_add64(&btree->bytes_dirty_leaf, size);
+ (void)__wt_atomic_add64(&cache->bytes_dirty_leaf, size);
+ }
(void)__wt_atomic_add64(&cache->pages_dirty_leaf, 1);
}
(void)__wt_atomic_addsize(&page->modify->bytes_dirty, size);
@@ -394,7 +396,7 @@ __wt_cache_page_evict(WT_SESSION_IMPL *session, WT_PAGE *page)
__wt_cache_decr_zero_uint64(session,
&cache->bytes_dirty_intl,
modify->bytes_dirty, "WT_CACHE.bytes_dirty_intl");
- else {
+ else if (!F_ISSET(btree, WT_BTREE_LSM_PRIMARY)) {
__wt_cache_decr_zero_uint64(session,
&cache->bytes_dirty_leaf,
modify->bytes_dirty, "WT_CACHE.bytes_dirty_leaf");
@@ -1543,6 +1545,48 @@ __wt_btree_lsm_over_size(WT_SESSION_IMPL *session, uint64_t maxsize)
}
/*
+ * __wt_btree_lsm_switch_primary --
+ * Switch a btree handle to/from the current primary chunk of an LSM tree.
+ */
+static inline void
+__wt_btree_lsm_switch_primary(WT_SESSION_IMPL *session, bool on)
+{
+ WT_BTREE *btree;
+ WT_CACHE *cache;
+ WT_PAGE *child, *root;
+ WT_PAGE_INDEX *pindex;
+ WT_REF *first;
+ size_t size;
+
+ btree = S2BT(session);
+ cache = S2C(session)->cache;
+ root = btree->root.page;
+
+ if (on) {
+ F_SET(btree, WT_BTREE_LSM_PRIMARY);
+ F_SET(btree, WT_BTREE_NO_EVICTION);
+ } else {
+ pindex = WT_INTL_INDEX_GET_SAFE(root);
+ first = pindex->index[0];
+
+ /*
+ * We're reaching down into the page without a hazard pointer, but
+ * that's OK because we know that no-eviction is set and so the page
+ * cannot disappear.
+ */
+ child = first->page;
+ if (!__wt_page_is_modified(child))
+ return;
+ size = child->modify->bytes_dirty;
+ (void)__wt_atomic_add64(&btree->bytes_dirty_leaf, size);
+ (void)__wt_atomic_add64(&cache->bytes_dirty_leaf, size);
+
+ F_CLR(btree, WT_BTREE_LSM_PRIMARY);
+ F_CLR(btree, WT_BTREE_NO_EVICTION);
+ }
+}
+
+/*
* __wt_split_descent_race --
* Return if we raced with an internal page split when descending the tree.
*/
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index 698fed77e77..c40f0f64b33 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -700,7 +700,7 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) {
if (btree->bulk_load_ok) {
btree->bulk_load_ok = false;
WT_WITH_BTREE(session, btree,
- __wt_btree_evictable(session, false));
+ __wt_btree_lsm_switch_primary(session, true));
}
}
diff --git a/src/lsm/lsm_work_unit.c b/src/lsm/lsm_work_unit.c
index 917104031fc..dfb8690f1ed 100644
--- a/src/lsm/lsm_work_unit.c
+++ b/src/lsm/lsm_work_unit.c
@@ -383,7 +383,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session,
* forced eviction.
*/
WT_ERR(__wt_session_get_btree(session, chunk->uri, NULL, NULL, 0));
- __wt_btree_evictable(session, true);
+ __wt_btree_lsm_switch_primary(session, false);
WT_ERR(__wt_session_release_btree(session));
/* Make sure we aren't pinning a transaction ID. */