summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/third_party/wiredtiger/dist/s_define.list1
-rw-r--r--src/third_party/wiredtiger/dist/stat_data.py1
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/include/btree_inline.h10
-rw-r--r--src/third_party/wiredtiger/src/include/stat.h10
-rw-r--r--src/third_party/wiredtiger/src/include/wiredtiger.in10
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c1
-rw-r--r--src/third_party/wiredtiger/src/support/stat.c2
-rw-r--r--src/third_party/wiredtiger/test/suite/test_stat08.py45
9 files changed, 70 insertions, 12 deletions
diff --git a/src/third_party/wiredtiger/dist/s_define.list b/src/third_party/wiredtiger/dist/s_define.list
index 8c0eb073007..a8b05f9c93c 100644
--- a/src/third_party/wiredtiger/dist/s_define.list
+++ b/src/third_party/wiredtiger/dist/s_define.list
@@ -84,6 +84,7 @@ WT_STAT_DECRV_BASE
WT_STAT_INCRV_ATOMIC
WT_STAT_INCRV_ATOMIC_BASE
WT_STAT_INCRV_BASE
+WT_STAT_SET_BASE
WT_STAT_WRITE
WT_TIMEDIFF_US
WT_TRACK_OP
diff --git a/src/third_party/wiredtiger/dist/stat_data.py b/src/third_party/wiredtiger/dist/stat_data.py
index 6b96b0186fc..a466e17fcb6 100644
--- a/src/third_party/wiredtiger/dist/stat_data.py
+++ b/src/third_party/wiredtiger/dist/stat_data.py
@@ -952,6 +952,7 @@ session_stats = [
SessionStat('cache_time', 'time waiting for cache (usecs)'),
SessionStat('lock_dhandle_wait', 'dhandle lock wait time (usecs)'),
SessionStat('lock_schema_wait', 'schema lock wait time (usecs)'),
+ SessionStat('txn_bytes_dirty', 'dirty bytes in this txn'),
SessionStat('read_time', 'page read from disk to cache time (usecs)'),
SessionStat('write_time', 'page write from cache to disk time (usecs)'),
]
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 2d7da58ae52..cc2630c0017 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-5.0",
- "commit": "c1e0d4e16d27c0e5e96bfd039762ca9f4fda6f7b"
+ "commit": "c7cea9c71fc7cab71c2bd16e874b3d0cd2e89123"
}
diff --git a/src/third_party/wiredtiger/src/include/btree_inline.h b/src/third_party/wiredtiger/src/include/btree_inline.h
index 198c36a1820..a1a61a951d8 100644
--- a/src/third_party/wiredtiger/src/include/btree_inline.h
+++ b/src/third_party/wiredtiger/src/include/btree_inline.h
@@ -225,6 +225,16 @@ __wt_cache_page_inmem_incr(WT_SESSION_IMPL *session, WT_PAGE *page, size_t size)
(void)__wt_atomic_addsize(&page->memory_footprint, size);
if (page->modify != NULL) {
+ /*
+ * For application threads, track the transaction bytes added to cache usage. We want to
+ * capture only the application's own changes to page data structures. Exclude changes to
+ * internal pages or changes that are the result of the application thread being co-opted
+ * into eviction work.
+ */
+ if (!F_ISSET(session, WT_SESSION_INTERNAL) &&
+ F_ISSET(session->txn, WT_TXN_RUNNING | WT_TXN_HAS_ID) &&
+ __wt_session_gen(session, WT_GEN_EVICT) == 0)
+ WT_STAT_SESSION_INCRV(session, txn_bytes_dirty, size);
if (!WT_PAGE_IS_INTERNAL(page) && !btree->lsm_primary) {
(void)__wt_atomic_add64(&cache->bytes_updates, size);
(void)__wt_atomic_add64(&btree->bytes_updates, size);
diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h
index d68df6806a7..f3dfac3da51 100644
--- a/src/third_party/wiredtiger/src/include/stat.h
+++ b/src/third_party/wiredtiger/src/include/stat.h
@@ -187,11 +187,16 @@ __wt_stats_clear(void *stats_arg, int slot)
WT_STAT_INCRV_ATOMIC_BASE(session, (stats)[(session)->stat_bucket], fld, value); \
} while (0)
#define WT_STAT_INCR(session, stats, fld) WT_STAT_INCRV(session, stats, fld, 1)
+#define WT_STAT_SET_BASE(session, stat, fld, value) \
+ do { \
+ if (WT_STAT_ENABLED(session)) \
+ (stat)->fld = (int64_t)(value); \
+ } while (0)
#define WT_STAT_SET(session, stats, fld, value) \
do { \
if (WT_STAT_ENABLED(session)) { \
__wt_stats_clear(stats, WT_STATS_FIELD_TO_OFFSET(stats, fld)); \
- (stats)[0]->fld = (int64_t)(value); \
+ WT_STAT_SET_BASE(session, (stats)[0], fld, value); \
} \
} while (0)
@@ -260,6 +265,8 @@ __wt_stats_clear(void *stats_arg, int slot)
*/
#define WT_STAT_SESSION_INCRV(session, fld, value) \
WT_STAT_INCRV_BASE(session, &(session)->stats, fld, value)
+#define WT_STAT_SESSION_SET(session, fld, value) \
+ WT_STAT_SET_BASE(session, &(session)->stats, fld, value)
/*
* Construct histogram increment functions to put the passed value into the right bucket. Bucket
@@ -1106,6 +1113,7 @@ struct __wt_session_stats {
int64_t bytes_read;
int64_t bytes_write;
int64_t lock_dhandle_wait;
+ int64_t txn_bytes_dirty;
int64_t read_time;
int64_t write_time;
int64_t lock_schema_wait;
diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in
index c632fa76d5c..0c9018d8510 100644
--- a/src/third_party/wiredtiger/src/include/wiredtiger.in
+++ b/src/third_party/wiredtiger/src/include/wiredtiger.in
@@ -7086,14 +7086,16 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection);
#define WT_STAT_SESSION_BYTES_WRITE 4001
/*! session: dhandle lock wait time (usecs) */
#define WT_STAT_SESSION_LOCK_DHANDLE_WAIT 4002
+/*! session: dirty bytes in this txn */
+#define WT_STAT_SESSION_TXN_BYTES_DIRTY 4003
/*! session: page read from disk to cache time (usecs) */
-#define WT_STAT_SESSION_READ_TIME 4003
+#define WT_STAT_SESSION_READ_TIME 4004
/*! session: page write from cache to disk time (usecs) */
-#define WT_STAT_SESSION_WRITE_TIME 4004
+#define WT_STAT_SESSION_WRITE_TIME 4005
/*! session: schema lock wait time (usecs) */
-#define WT_STAT_SESSION_LOCK_SCHEMA_WAIT 4005
+#define WT_STAT_SESSION_LOCK_SCHEMA_WAIT 4006
/*! session: time waiting for cache (usecs) */
-#define WT_STAT_SESSION_CACHE_TIME 4006
+#define WT_STAT_SESSION_CACHE_TIME 4007
/*! @} */
/*
* Statistics section: END
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index df63a3e44c2..bc9656d92e5 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -1620,6 +1620,7 @@ __session_begin_transaction(WT_SESSION *wt_session, const char *config)
session = (WT_SESSION_IMPL *)wt_session;
SESSION_API_CALL_PREPARE_NOT_ALLOWED(session, begin_transaction, config, cfg);
WT_STAT_CONN_INCR(session, txn_begin);
+ WT_STAT_SESSION_SET(session, txn_bytes_dirty, 0);
WT_ERR(__wt_txn_context_check(session, false));
diff --git a/src/third_party/wiredtiger/src/support/stat.c b/src/third_party/wiredtiger/src/support/stat.c
index 4a4bf31d83c..550561dd3a5 100644
--- a/src/third_party/wiredtiger/src/support/stat.c
+++ b/src/third_party/wiredtiger/src/support/stat.c
@@ -2767,6 +2767,7 @@ static const char *const __stats_session_desc[] = {
"session: bytes read into cache",
"session: bytes written from cache",
"session: dhandle lock wait time (usecs)",
+ "session: dirty bytes in this txn",
"session: page read from disk to cache time (usecs)",
"session: page write from cache to disk time (usecs)",
"session: schema lock wait time (usecs)",
@@ -2793,6 +2794,7 @@ __wt_stat_session_clear_single(WT_SESSION_STATS *stats)
stats->bytes_read = 0;
stats->bytes_write = 0;
stats->lock_dhandle_wait = 0;
+ stats->txn_bytes_dirty = 0;
stats->read_time = 0;
stats->write_time = 0;
stats->lock_schema_wait = 0;
diff --git a/src/third_party/wiredtiger/test/suite/test_stat08.py b/src/third_party/wiredtiger/test/suite/test_stat08.py
index 7e91932d1d7..b8ae86ac2b8 100644
--- a/src/third_party/wiredtiger/test/suite/test_stat08.py
+++ b/src/third_party/wiredtiger/test/suite/test_stat08.py
@@ -33,14 +33,29 @@ import wiredtiger, wttest
# Session statistics for bytes read into the cache.
class test_stat08(wttest.WiredTigerTestCase):
- nentries = 350000
- conn_config = 'cache_size=10MB,statistics=(all)'
- entry_value = "abcde" * 40
+ nentries = 100000
+ # Leave the cache size on the default setting to avoid filling up the cache
+ # too much and triggering unnecessary rollbacks. But make the value fairly
+ # large to make obvious change to the statistics.
+ conn_config = 'statistics=(all)'
+ entry_value = "abcde" * 400
BYTES_READ = wiredtiger.stat.session.bytes_read
READ_TIME = wiredtiger.stat.session.read_time
session_stats = { BYTES_READ : "session: bytes read into cache", \
READ_TIME : "session: page read from disk to cache time (usecs)"}
+ def get_stat(self, stat):
+ statc = self.session.open_cursor('statistics:session', None, None)
+ val = statc[stat][2]
+ statc.close()
+ return val
+
+ def get_cstat(self, stat):
+ statc = self.session.open_cursor('statistics:', None, None)
+ val = statc[stat][2]
+ statc.close()
+ return val
+
def check_stats(self, cur, k):
#
# Some Windows machines lack the time granularity to detect microseconds.
@@ -62,12 +77,30 @@ class test_stat08(wttest.WiredTigerTestCase):
self.session = self.conn.open_session()
self.session.create("table:test_stat08",
"key_format=i,value_format=S")
- cursor = self.session.open_cursor('table:test_stat08', None, None)
+ cursor = self.session.open_cursor('table:test_stat08', None, "debug=(release_evict)")
+ self.session.begin_transaction()
+ txn_dirty = self.get_stat(wiredtiger.stat.session.txn_bytes_dirty)
+ cache_dirty = self.get_cstat(wiredtiger.stat.conn.cache_bytes_dirty)
+ self.assertEqual(txn_dirty, 0)
+ self.assertLessEqual(txn_dirty, cache_dirty)
# Write the entries.
- for i in range(0, self.nentries):
+ for i in range(1, self.nentries):
+ txn_dirty_before = self.get_stat(wiredtiger.stat.session.txn_bytes_dirty)
cursor[i] = self.entry_value
+ txn_dirty_after = self.get_stat(wiredtiger.stat.session.txn_bytes_dirty)
+ self.assertLess(txn_dirty_before, txn_dirty_after)
+ # Since we're using an explicit transaction, we need to resolve somewhat frequently.
+ # So check the statistics and restart the transaction every 200 operations.
+ if i % 200 == 0:
+ cache_dirty_txn = self.get_cstat(wiredtiger.stat.conn.cache_bytes_dirty)
+ # Make sure the txn's dirty bytes doesn't exceed the cache.
+ self.assertLessEqual(txn_dirty_after, cache_dirty_txn)
+ self.session.commit_transaction()
+ self.session.begin_transaction()
+ txn_dirty = self.get_stat(wiredtiger.stat.session.txn_bytes_dirty)
+ self.assertEqual(txn_dirty, 0)
+ self.session.commit_transaction()
cursor.reset()
-
# Read the entries.
i = 0
for key, value in cursor: