Skip to content

Commit 838d364

Browse files
lukechEvergreen Agent
authored andcommitted
Import wiredtiger: 723f5e15d49dbe2caf944ed270b4f22b4fd282d6 from branch mongodb-master
ref: a7f6fa07f9..723f5e15d4 for: 6.3.0-rc0 WT-10197 Track eviction timeline
1 parent b29429e commit 838d364

File tree

13 files changed

+542
-442
lines changed

13 files changed

+542
-442
lines changed

src/third_party/wiredtiger/dist/stat_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def __init__(self, name, desc, flags=''):
265265
CacheStat('cache_eviction_internal_pages_already_queued', 'internal pages seen by eviction walk that are already queued'),
266266
CacheStat('cache_eviction_internal_pages_queued', 'internal pages queued for eviction'),
267267
CacheStat('cache_eviction_internal_pages_seen', 'internal pages seen by eviction walk'),
268-
CacheStat('cache_eviction_maximum_page_size', 'maximum page size at eviction', 'no_clear,no_scale,size'),
268+
CacheStat('cache_eviction_maximum_page_size', 'maximum page size seen at eviction', 'no_clear,no_scale,size'),
269+
CacheStat('cache_eviction_maximum_seconds', 'maximum seconds spent at a single eviction', 'no_clear,no_scale,size'),
269270
CacheStat('cache_eviction_pages_already_queued', 'pages seen by eviction walk that are already queued'),
270271
CacheStat('cache_eviction_pages_in_parallel_with_checkpoint', 'pages evicted in parallel with checkpoint'),
271272
CacheStat('cache_eviction_pages_queued', 'pages queued for eviction'),
@@ -499,6 +500,8 @@ def __init__(self, name, desc, flags=''):
499500
##########################################
500501
# Reconciliation statistics
501502
##########################################
503+
RecStat('rec_maximum_hs_wrapup_seconds', 'maximum seconds spent in moving updates to the history store in a reconciliation', 'no_clear,no_scale,size'),
504+
RecStat('rec_maximum_image_build_seconds', 'maximum seconds spent in building a disk image in a reconciliation', 'no_clear,no_scale,size'),
502505
RecStat('rec_maximum_seconds', 'maximum seconds spent in a reconciliation call', 'no_clear,no_scale,size'),
503506
RecStat('rec_overflow_key_leaf', 'leaf-page overflow keys'),
504507
RecStat('rec_pages_with_prepare', 'page reconciliation calls that resulted in values with prepared transaction metadata'),

src/third_party/wiredtiger/import.data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"vendor": "wiredtiger",
33
"github": "wiredtiger/wiredtiger.git",
44
"branch": "mongodb-master",
5-
"commit": "a7f6fa07f90d701b73206a768ae0cc6fb50ff9b4"
5+
"commit": "723f5e15d49dbe2caf944ed270b4f22b4fd282d6"
66
}

src/third_party/wiredtiger/src/conn/conn_cache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session)
320320
WT_STAT_SET(session, stats, cache_bytes_updates, __wt_cache_bytes_updates(cache));
321321

322322
WT_STAT_SET(session, stats, cache_eviction_maximum_page_size, cache->evict_max_page_size);
323+
WT_STAT_SET(session, stats, cache_eviction_maximum_seconds, cache->evict_max_seconds);
323324
WT_STAT_SET(
324325
session, stats, cache_pages_dirty, cache->pages_dirty_intl + cache->pages_dirty_leaf);
325326

@@ -338,6 +339,9 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session)
338339
if (conn->evict_server_running)
339340
WT_STAT_SET(session, stats, cache_eviction_walks_active, cache->walk_session->nhazard);
340341

342+
WT_STAT_SET(session, stats, rec_maximum_hs_wrapup_seconds, conn->rec_maximum_hs_wrapup_seconds);
343+
WT_STAT_SET(
344+
session, stats, rec_maximum_image_build_seconds, conn->rec_maximum_image_build_seconds);
341345
WT_STAT_SET(session, stats, rec_maximum_seconds, conn->rec_maximum_seconds);
342346
}
343347

src/third_party/wiredtiger/src/evict/evict_page.c

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,15 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, uint8_t previous_state, uint32
104104
WT_CONNECTION_IMPL *conn;
105105
WT_DECL_RET;
106106
WT_PAGE *page;
107-
uint64_t time_start, time_stop;
107+
uint64_t eviction_time, eviction_time_seconds;
108108
bool clean_page, closing, force_evict_hs, inmem_split, local_gen, tree_dead;
109109

110110
conn = S2C(session);
111111
page = ref->page;
112112
closing = LF_ISSET(WT_EVICT_CALL_CLOSING);
113113
force_evict_hs = false;
114114
local_gen = false;
115+
eviction_time = eviction_time_seconds = 0;
115116

116117
__wt_verbose(
117118
session, WT_VERB_EVICT, "page %p (%s)", (void *)page, __wt_page_type_string(page->type));
@@ -129,13 +130,14 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, uint8_t previous_state, uint32
129130
__wt_session_gen_enter(session, WT_GEN_EVICT);
130131
}
131132

133+
WT_CLEAR(session->reconcile_timeline);
134+
WT_CLEAR(session->evict_timeline);
135+
session->evict_timeline.evict_start = __wt_clock(session);
132136
/*
133-
* Track how long forcible eviction took. Immediately increment the forcible eviction counter,
134-
* we might do an in-memory split and not an eviction, which skips the other statistics.
137+
* Immediately increment the forcible eviction counter, we might do an in-memory split and not
138+
* an eviction, which skips the other statistics.
135139
*/
136-
time_start = 0;
137140
if (LF_ISSET(WT_EVICT_CALL_URGENT)) {
138-
time_start = __wt_clock(session);
139141
WT_STAT_CONN_INCR(session, cache_eviction_force);
140142

141143
/*
@@ -227,19 +229,18 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, uint8_t previous_state, uint32
227229
* We have loaded the new disk image and updated the tree structure. We can no longer fail after
228230
* this point.
229231
*/
230-
231-
if (time_start != 0) {
232-
time_stop = __wt_clock(session);
232+
session->evict_timeline.evict_finish = __wt_clock(session);
233+
eviction_time =
234+
WT_CLOCKDIFF_US(session->evict_timeline.evict_finish, session->evict_timeline.evict_start);
235+
if (LF_ISSET(WT_EVICT_CALL_URGENT)) {
233236
if (force_evict_hs)
234237
WT_STAT_CONN_INCR(session, cache_eviction_force_hs_success);
235238
if (clean_page) {
236239
WT_STAT_CONN_INCR(session, cache_eviction_force_clean);
237-
WT_STAT_CONN_INCRV(
238-
session, cache_eviction_force_clean_time, WT_CLOCKDIFF_US(time_stop, time_start));
240+
WT_STAT_CONN_INCRV(session, cache_eviction_force_clean_time, eviction_time);
239241
} else {
240242
WT_STAT_CONN_INCR(session, cache_eviction_force_dirty);
241-
WT_STAT_CONN_INCRV(
242-
session, cache_eviction_force_dirty_time, WT_CLOCKDIFF_US(time_stop, time_start));
243+
WT_STAT_CONN_INCRV(session, cache_eviction_force_dirty_time, eviction_time);
243244
}
244245
}
245246
if (clean_page)
@@ -255,20 +256,32 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, uint8_t previous_state, uint32
255256
err:
256257
if (!closing)
257258
__evict_exclusive_clear(session, ref, previous_state);
258-
259-
if (time_start != 0) {
260-
time_stop = __wt_clock(session);
259+
session->evict_timeline.evict_finish = __wt_clock(session);
260+
eviction_time = WT_CLOCKDIFF_US(
261+
session->evict_timeline.evict_finish, session->evict_timeline.evict_start);
262+
if (LF_ISSET(WT_EVICT_CALL_URGENT)) {
261263
if (force_evict_hs)
262264
WT_STAT_CONN_INCR(session, cache_eviction_force_hs_fail);
263265
WT_STAT_CONN_INCR(session, cache_eviction_force_fail);
264-
WT_STAT_CONN_INCRV(
265-
session, cache_eviction_force_fail_time, WT_CLOCKDIFF_US(time_stop, time_start));
266+
WT_STAT_CONN_INCRV(session, cache_eviction_force_fail_time, eviction_time);
266267
}
267268

268269
WT_STAT_CONN_DATA_INCR(session, cache_eviction_fail);
269270
}
270271

271272
done:
273+
eviction_time_seconds = eviction_time / WT_MILLION;
274+
if (eviction_time_seconds > conn->cache->evict_max_seconds)
275+
conn->cache->evict_max_seconds = eviction_time_seconds;
276+
if (eviction_time_seconds > 60)
277+
__wt_verbose_warning(session, WT_VERB_EVICT,
278+
"Eviction took more than 1 minute (%" PRIu64 "). Building disk image took %" PRIu64
279+
"us. History store wrapup took %" PRIu64 "us.",
280+
eviction_time,
281+
WT_CLOCKDIFF_US(session->reconcile_timeline.image_build_finish,
282+
session->reconcile_timeline.image_build_start),
283+
WT_CLOCKDIFF_US(session->reconcile_timeline.hs_wrapup_finish,
284+
session->reconcile_timeline.hs_wrapup_start));
272285
/* Leave any local eviction generation. */
273286
if (local_gen)
274287
__wt_session_gen_leave(session, WT_GEN_EVICT);

src/third_party/wiredtiger/src/include/cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct __wt_cache {
9898
uint64_t app_evicts; /* Pages evicted by user threads */
9999

100100
uint64_t evict_max_page_size; /* Largest page seen at eviction */
101+
uint64_t evict_max_seconds; /* Longest seconds spent at a single eviction */
101102
struct timespec stuck_time; /* Stuck time */
102103

103104
/*

src/third_party/wiredtiger/src/include/connection.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,10 @@ struct __wt_connection_impl {
414414
uint32_t stat_flags; /* Options declared in flags.py */
415415

416416
/* Connection statistics */
417-
uint64_t rec_maximum_seconds; /* Maximum seconds reconciliation took. */
417+
uint64_t
418+
rec_maximum_hs_wrapup_seconds; /* Maximum seconds moving updates to history store took. */
419+
uint64_t rec_maximum_image_build_seconds; /* Maximum seconds building disk image took. */
420+
uint64_t rec_maximum_seconds; /* Maximum seconds reconciliation took. */
418421
WT_CONNECTION_STATS *stats[WT_COUNTER_SLOTS];
419422
WT_CONNECTION_STATS *stat_array;
420423

src/third_party/wiredtiger/src/include/session.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ struct __wt_session_impl {
141141
} * scratch_track;
142142
#endif
143143

144+
/* Record the important timestamps of each stage in an reconciliation. */
145+
struct __wt_reconcile_timeline {
146+
uint64_t reconcile_start;
147+
uint64_t image_build_start;
148+
uint64_t image_build_finish;
149+
uint64_t hs_wrapup_start;
150+
uint64_t hs_wrapup_finish;
151+
uint64_t reconcile_finish;
152+
} reconcile_timeline;
153+
154+
/*
155+
* Record the important timestamps of each stage in an eviction. If an eviction takes a long
156+
* time and times out, we can trace the time usage of each stage from this information.
157+
*/
158+
struct __wt_evict_timeline {
159+
uint64_t evict_start;
160+
uint64_t evict_finish;
161+
} evict_timeline;
162+
144163
WT_ITEM err; /* Error buffer */
145164

146165
WT_TXN_ISOLATION isolation;

src/third_party/wiredtiger/src/include/stat.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ struct __wt_connection_stats {
487487
int64_t cache_eviction_split_leaf;
488488
int64_t cache_bytes_max;
489489
int64_t cache_eviction_maximum_page_size;
490+
int64_t cache_eviction_maximum_seconds;
490491
int64_t cache_eviction_dirty;
491492
int64_t cache_eviction_app_dirty;
492493
int64_t cache_timed_out_ops;
@@ -743,6 +744,8 @@ struct __wt_connection_stats {
743744
int64_t rec_page_delete_fast;
744745
int64_t rec_overflow_key_leaf;
745746
int64_t rec_maximum_seconds;
747+
int64_t rec_maximum_image_build_seconds;
748+
int64_t rec_maximum_hs_wrapup_seconds;
746749
int64_t rec_pages;
747750
int64_t rec_pages_eviction;
748751
int64_t rec_pages_with_prepare;

0 commit comments

Comments
 (0)