diff options
-rw-r--r-- | dist/stat_data.py | 6 | ||||
-rw-r--r-- | src/btree/bt_page.c | 20 | ||||
-rw-r--r-- | src/include/stat.h | 2 | ||||
-rw-r--r-- | src/include/wiredtiger.in | 8 | ||||
-rw-r--r-- | src/support/stat.c | 6 |
5 files changed, 22 insertions, 20 deletions
diff --git a/dist/stat_data.py b/dist/stat_data.py index c6ba0f83270..a6a047fd10e 100644 --- a/dist/stat_data.py +++ b/dist/stat_data.py @@ -309,11 +309,11 @@ connection_stats = [ ########################################## # Yield statistics ########################################## - YieldStat('page_locked_blocked', 'page acquire locked blocked'), - YieldStat('page_read_blocked', 'page acquire read blocked'), YieldStat('page_busy_blocked', 'page acquire busy blocked'), YieldStat('page_forcible_evict_blocked', 'page acquire eviction blocked'), - YieldStat('page_in_sleep', 'page acquire time sleeping in microseconds'), + YieldStat('page_locked_blocked', 'page acquire locked blocked'), + YieldStat('page_read_blocked', 'page acquire read blocked'), + YieldStat('page_sleep', 'page acquire time sleeping (usecs)'), ] connection_stats = sorted(connection_stats, key=attrgetter('name')) diff --git a/src/btree/bt_page.c b/src/btree/bt_page.c index fb38b5c7220..a662933e40b 100644 --- a/src/btree/bt_page.c +++ b/src/btree/bt_page.c @@ -67,10 +67,10 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags { WT_DECL_RET; WT_PAGE *page; - int busy, force_attempts, oldgen, sleep_cnt, wait_cnt; + u_int sleep_cnt, wait_cnt; + int busy, force_attempts, oldgen; - wait_cnt = 1; - for (force_attempts = oldgen = 0;;) { + for (force_attempts = oldgen = 0, wait_cnt = 0;;) { switch (ref->state) { case WT_REF_DISK: case WT_REF_DELETED: @@ -157,15 +157,17 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags WT_ILLEGAL_VALUE(session); } - /* We failed to get the page -- yield before retrying. */ - if (wait_cnt < 5) { + /* + * We failed to get the page -- yield before retrying, and if + * we've yielded a few times start sleeping so we don't burn + * CPU to no purpose. + */ + if (++wait_cnt < 5) __wt_yield(); - wait_cnt++; - } else { + else { wait_cnt *= 2; sleep_cnt = WT_MAX(wait_cnt, 10000); - WT_STAT_FAST_CONN_INCRV( - session, page_in_sleep, sleep_cnt); + WT_STAT_FAST_CONN_INCRV(session, page_sleep, sleep_cnt); __wt_sleep(0, sleep_cnt); } } diff --git a/src/include/stat.h b/src/include/stat.h index dcd33554738..8bdc377ac44 100644 --- a/src/include/stat.h +++ b/src/include/stat.h @@ -238,9 +238,9 @@ struct __wt_connection_stats { WT_STATS memory_grow; WT_STATS page_busy_blocked; WT_STATS page_forcible_evict_blocked; - WT_STATS page_in_sleep; WT_STATS page_locked_blocked; WT_STATS page_read_blocked; + WT_STATS page_sleep; WT_STATS read_io; WT_STATS rec_pages; WT_STATS rec_pages_eviction; diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in index f7bbd9c223a..ae0916cc4d5 100644 --- a/src/include/wiredtiger.in +++ b/src/include/wiredtiger.in @@ -3301,12 +3301,12 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_CONN_PAGE_BUSY_BLOCKED 1105 /*! thread-yield: page acquire eviction blocked */ #define WT_STAT_CONN_PAGE_FORCIBLE_EVICT_BLOCKED 1106 -/*! thread-yield: page acquire time sleeping in microseconds */ -#define WT_STAT_CONN_PAGE_IN_SLEEP 1107 /*! thread-yield: page acquire locked blocked */ -#define WT_STAT_CONN_PAGE_LOCKED_BLOCKED 1108 +#define WT_STAT_CONN_PAGE_LOCKED_BLOCKED 1107 /*! thread-yield: page acquire read blocked */ -#define WT_STAT_CONN_PAGE_READ_BLOCKED 1109 +#define WT_STAT_CONN_PAGE_READ_BLOCKED 1108 +/*! thread-yield: page acquire time sleeping (usecs) */ +#define WT_STAT_CONN_PAGE_SLEEP 1109 /*! connection: total read I/Os */ #define WT_STAT_CONN_READ_IO 1110 /*! reconciliation: page reconciliation calls */ diff --git a/src/support/stat.c b/src/support/stat.c index 551da05b13d..c93168cd9a1 100644 --- a/src/support/stat.c +++ b/src/support/stat.c @@ -488,8 +488,8 @@ __wt_stat_init_connection_stats(WT_CONNECTION_STATS *stats) "thread-yield: page acquire locked blocked"; stats->page_read_blocked.desc = "thread-yield: page acquire read blocked"; - stats->page_in_sleep.desc = - "thread-yield: page acquire time sleeping in microseconds"; + stats->page_sleep.desc = + "thread-yield: page acquire time sleeping (usecs)"; stats->txn_begin.desc = "transaction: transaction begins"; stats->txn_checkpoint_running.desc = "transaction: transaction checkpoint currently running"; @@ -622,7 +622,7 @@ __wt_stat_refresh_connection_stats(void *stats_arg) stats->page_forcible_evict_blocked.v = 0; stats->page_locked_blocked.v = 0; stats->page_read_blocked.v = 0; - stats->page_in_sleep.v = 0; + stats->page_sleep.v = 0; stats->txn_begin.v = 0; stats->txn_checkpoint.v = 0; stats->txn_fail_cache.v = 0; |