summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/include')
-rw-r--r--src/third_party/wiredtiger/src/include/btree.i2
-rw-r--r--src/third_party/wiredtiger/src/include/cache.h4
-rw-r--r--src/third_party/wiredtiger/src/include/cache.i94
-rw-r--r--src/third_party/wiredtiger/src/include/thread_group.h15
4 files changed, 77 insertions, 38 deletions
diff --git a/src/third_party/wiredtiger/src/include/btree.i b/src/third_party/wiredtiger/src/include/btree.i
index 6e32c1bc195..a9ce4f754a9 100644
--- a/src/third_party/wiredtiger/src/include/btree.i
+++ b/src/third_party/wiredtiger/src/include/btree.i
@@ -406,7 +406,7 @@ __wt_cache_page_evict(WT_SESSION_IMPL *session, WT_PAGE *page)
/* Update pages and bytes evicted. */
(void)__wt_atomic_add64(&cache->bytes_evict, page->memory_footprint);
- (void)__wt_atomic_add64(&cache->pages_evict, 1);
+ (void)__wt_atomic_addv64(&cache->pages_evict, 1);
}
/*
diff --git a/src/third_party/wiredtiger/src/include/cache.h b/src/third_party/wiredtiger/src/include/cache.h
index 515135f26ab..b24b625aec4 100644
--- a/src/third_party/wiredtiger/src/include/cache.h
+++ b/src/third_party/wiredtiger/src/include/cache.h
@@ -66,7 +66,7 @@ struct __wt_cache {
uint64_t bytes_dirty_leaf;
uint64_t pages_dirty_leaf;
uint64_t bytes_evict; /* Bytes/pages discarded by eviction */
- uint64_t pages_evict;
+ volatile uint64_t pages_evict;
uint64_t pages_evicted; /* Pages evicted during a pass */
uint64_t bytes_image; /* Bytes of disk images */
uint64_t bytes_inmem; /* Bytes/pages in memory */
@@ -175,7 +175,7 @@ struct __wt_cache {
#define WT_CACHE_EVICT_CLEAN_HARD 0x002 /* Clean % blocking app threads */
#define WT_CACHE_EVICT_DIRTY 0x004 /* Evict dirty pages */
#define WT_CACHE_EVICT_DIRTY_HARD 0x008 /* Dirty % blocking app threads */
-#define WT_CACHE_EVICT_SCRUB 0x010 /* Scrub dirty pages pages */
+#define WT_CACHE_EVICT_SCRUB 0x010 /* Scrub dirty pages */
#define WT_CACHE_EVICT_URGENT 0x020 /* Pages are in the urgent queue */
#define WT_CACHE_EVICT_ALL (WT_CACHE_EVICT_CLEAN | WT_CACHE_EVICT_DIRTY)
#define WT_CACHE_EVICT_MASK 0x0FF
diff --git a/src/third_party/wiredtiger/src/include/cache.i b/src/third_party/wiredtiger/src/include/cache.i
index b5605769f1a..4255d04ec37 100644
--- a/src/third_party/wiredtiger/src/include/cache.i
+++ b/src/third_party/wiredtiger/src/include/cache.i
@@ -193,7 +193,7 @@ __wt_cache_bytes_other(WT_CACHE *cache)
* __wt_session_can_wait --
* Return if a session available for a potentially slow operation.
*/
-static inline int
+static inline bool
__wt_session_can_wait(WT_SESSION_IMPL *session)
{
/*
@@ -202,17 +202,71 @@ __wt_session_can_wait(WT_SESSION_IMPL *session)
* the system cache.
*/
if (!F_ISSET(session, WT_SESSION_CAN_WAIT))
- return (0);
+ return (false);
/*
* LSM sets the no-eviction flag when holding the LSM tree lock, in that
* case, or when holding the schema lock, we don't want to highjack the
* thread for eviction.
*/
- if (F_ISSET(session, WT_SESSION_NO_EVICTION | WT_SESSION_LOCKED_SCHEMA))
- return (0);
+ return (!F_ISSET(
+ session, WT_SESSION_NO_EVICTION | WT_SESSION_LOCKED_SCHEMA));
+}
+
+/*
+ * __wt_eviction_clean_needed --
+ * Return if an application thread should do eviction due to the total
+ * volume of dirty data in cache.
+ */
+static inline bool
+__wt_eviction_clean_needed(WT_SESSION_IMPL *session, u_int *pct_fullp)
+{
+ WT_CACHE *cache;
+ uint64_t bytes_inuse, bytes_max;
+
+ cache = S2C(session)->cache;
+
+ /*
+ * Avoid division by zero if the cache size has not yet been set in a
+ * shared cache.
+ */
+ bytes_max = S2C(session)->cache_size + 1;
+ bytes_inuse = __wt_cache_bytes_inuse(cache);
+
+ if (pct_fullp != NULL)
+ *pct_fullp = (u_int)((100 * bytes_inuse) / bytes_max);
+
+ return (bytes_inuse > (cache->eviction_trigger * bytes_max) / 100);
+}
+
+/*
+ * __wt_eviction_dirty_needed --
+ * Return if an application thread should do eviction due to the total
+ * volume of dirty data in cache.
+ */
+static inline bool
+__wt_eviction_dirty_needed(WT_SESSION_IMPL *session, u_int *pct_fullp)
+{
+ WT_CACHE *cache;
+ double dirty_trigger;
+ uint64_t dirty_inuse, bytes_max;
+
+ cache = S2C(session)->cache;
+
+ /*
+ * Avoid division by zero if the cache size has not yet been set in a
+ * shared cache.
+ */
+ bytes_max = S2C(session)->cache_size + 1;
+ dirty_inuse = __wt_cache_dirty_leaf_inuse(cache);
+
+ if (pct_fullp != NULL)
+ *pct_fullp = (u_int)((100 * dirty_inuse) / bytes_max);
+
+ if ((dirty_trigger = cache->eviction_scrub_limit) < 1.0)
+ dirty_trigger = (double)cache->eviction_dirty_trigger;
- return (1);
+ return (dirty_inuse > (uint64_t)(dirty_trigger * bytes_max) / 100);
}
/*
@@ -223,42 +277,30 @@ __wt_session_can_wait(WT_SESSION_IMPL *session)
static inline bool
__wt_eviction_needed(WT_SESSION_IMPL *session, bool busy, u_int *pct_fullp)
{
- WT_CONNECTION_IMPL *conn;
WT_CACHE *cache;
- double dirty_trigger;
- uint64_t bytes_inuse, bytes_max, dirty_inuse;
u_int pct_dirty, pct_full;
+ bool clean_needed, dirty_needed;
- conn = S2C(session);
- cache = conn->cache;
+ cache = S2C(session)->cache;
/*
* If the connection is closing we do not need eviction from an
* application thread. The eviction subsystem is already closed.
*/
- if (F_ISSET(conn, WT_CONN_CLOSING))
+ if (F_ISSET(S2C(session), WT_CONN_CLOSING))
return (false);
- /*
- * Avoid division by zero if the cache size has not yet been set in a
- * shared cache.
- */
- bytes_max = conn->cache_size + 1;
- bytes_inuse = __wt_cache_bytes_inuse(cache);
- dirty_inuse = __wt_cache_dirty_leaf_inuse(cache);
+ clean_needed = __wt_eviction_clean_needed(session, &pct_full);
+ dirty_needed = __wt_eviction_dirty_needed(session, &pct_dirty);
/*
* Calculate the cache full percentage; anything over the trigger means
* we involve the application thread.
*/
- if (pct_fullp != NULL) {
- pct_full = (u_int)((100 * bytes_inuse) / bytes_max);
- pct_dirty = (u_int)((100 * dirty_inuse) / bytes_max);
-
+ if (pct_fullp != NULL)
*pct_fullp = (u_int)WT_MAX(0, 100 - WT_MIN(
(int)cache->eviction_trigger - (int)pct_full,
(int)cache->eviction_dirty_trigger - (int)pct_dirty));
- }
/*
* Only check the dirty trigger when the session is not busy.
@@ -268,11 +310,7 @@ __wt_eviction_needed(WT_SESSION_IMPL *session, bool busy, u_int *pct_fullp)
* The next transaction in this session will not be able to start until
* the cache is under the limit.
*/
- if ((dirty_trigger = cache->eviction_scrub_limit) < 1.0)
- dirty_trigger = (double)cache->eviction_dirty_trigger;
- return (bytes_inuse > (cache->eviction_trigger * bytes_max) / 100 ||
- (!busy &&
- dirty_inuse > (uint64_t)(dirty_trigger * bytes_max) / 100));
+ return (clean_needed || (!busy && dirty_needed));
}
/*
diff --git a/src/third_party/wiredtiger/src/include/thread_group.h b/src/third_party/wiredtiger/src/include/thread_group.h
index f946dcab144..76758a090c4 100644
--- a/src/third_party/wiredtiger/src/include/thread_group.h
+++ b/src/third_party/wiredtiger/src/include/thread_group.h
@@ -14,7 +14,14 @@ struct __wt_thread {
WT_SESSION_IMPL *session;
u_int id;
wt_thread_t tid;
-#define WT_THREAD_RUN 0x01
+
+ /*
+ * WT_THREAD and thread-group function flags, merged because
+ * WT_THREAD_PANIC_FAIL appears in both groups.
+ */
+#define WT_THREAD_CAN_WAIT 0x01 /* WT_SESSION_CAN_WAIT */
+#define WT_THREAD_PANIC_FAIL 0x02 /* panic if the thread fails */
+#define WT_THREAD_RUN 0x04 /* thread is running */
uint32_t flags;
/* The runner function used by all threads. */
@@ -22,12 +29,6 @@ struct __wt_thread {
};
/*
- * Flags for thread group functions.
- */
-#define WT_THREAD_CAN_WAIT 0x01
-#define WT_THREAD_PANIC_FAIL 0x02
-
-/*
* WT_THREAD_GROUP --
* Encapsulation of a group of utility threads.
*/