diff options
author | Susan LoVerso <sue@mongodb.com> | 2016-04-14 13:58:57 -0400 |
---|---|---|
committer | Susan LoVerso <sue@mongodb.com> | 2016-04-14 13:58:57 -0400 |
commit | c38a90082a1a86a5a4e78e754612949e0a9c482d (patch) | |
tree | cfbe43c4723ecf26c6ea580ff10a32877ed5ce74 /src | |
parent | 4a278393bda27e62e2e08fb4d000350c0ce83578 (diff) | |
download | mongo-c38a90082a1a86a5a4e78e754612949e0a9c482d.tar.gz |
WT-2546 Compute eviction values without using stat fields.
Diffstat (limited to 'src')
-rw-r--r-- | src/conn/conn_cache.c | 6 | ||||
-rw-r--r-- | src/evict/evict_lru.c | 30 | ||||
-rw-r--r-- | src/include/cache.h | 4 |
3 files changed, 21 insertions, 19 deletions
diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c index 4d33ac608bb..15a346b4723 100644 --- a/src/conn/conn_cache.c +++ b/src/conn/conn_cache.c @@ -209,6 +209,12 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session) WT_STAT_SET(session, stats, cache_bytes_max, conn->cache_size); WT_STAT_SET(session, stats, cache_bytes_inuse, inuse); + WT_STAT_SET(session, stats, cache_eviction_app, cache->app_evicts); + WT_STAT_SET(session, + stats, cache_eviction_server_evicting, cache->server_evicts); + WT_STAT_SET(session, + stats, cache_eviction_worker_evicting, cache->worker_evicts); + WT_STAT_SET(session, stats, cache_overhead, cache->overhead_pct); WT_STAT_SET( session, stats, cache_pages_inuse, __wt_cache_pages_inuse(cache)); diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index 0cc1afd4cea..09a564ff2a8 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -900,8 +900,9 @@ __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session) static int __evict_lru_pages(WT_SESSION_IMPL *session, bool is_server) { + WT_CACHE *cache; WT_DECL_RET; - uint64_t app_evict_percent, app_evict, server_evict, worker_evict; + uint64_t app_evict_percent, total_evict; /* * The server will not help evict if the workers are coping with @@ -909,17 +910,11 @@ __evict_lru_pages(WT_SESSION_IMPL *session, bool is_server) * evicted by application threads. */ if (is_server && S2C(session)->evict_workers > 1) { - app_evict = WT_STAT_READ(S2C(session)->stats, - cache_eviction_app); - - server_evict = WT_STAT_READ(S2C(session)->stats, - cache_eviction_server_evicting); - - worker_evict = WT_STAT_READ(S2C(session)->stats, - cache_eviction_worker_evicting); - - app_evict_percent = (100 * app_evict) / - (server_evict + worker_evict + 1); + cache = S2C(session)->cache; + total_evict = cache->app_evicts + + cache->server_evicts + cache->worker_evicts; + app_evict_percent = (100 * cache->app_evicts) / + (total_evict + 1); if (app_evict_percent < 5) { WT_STAT_FAST_CONN_INCR(session, cache_eviction_server_not_evicting); @@ -1620,25 +1615,25 @@ static int __evict_page(WT_SESSION_IMPL *session, bool is_server) { WT_BTREE *btree; + WT_CACHE *cache; WT_DECL_RET; WT_REF *ref; WT_RET(__evict_get_ref(session, is_server, &btree, &ref)); WT_ASSERT(session, ref->state == WT_REF_LOCKED); + cache = S2C(session)->cache; /* * An internal session flags either the server itself or an eviction * worker thread. */ if (F_ISSET(session, WT_SESSION_INTERNAL)) { if (is_server) - WT_STAT_FAST_CONN_INCR( - session, cache_eviction_server_evicting); + cache->server_evicts++; else - WT_STAT_FAST_CONN_INCR( - session, cache_eviction_worker_evicting); + cache->worker_evicts++; } else - WT_STAT_FAST_CONN_INCR(session, cache_eviction_app); + cache->app_evicts++; /* * In case something goes wrong, don't pick the same set of pages every @@ -1732,7 +1727,6 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) /* Evict a page. */ switch (ret = __evict_page(session, false)) { case 0: - cache->app_evicts++; if (txn_busy) return (0); /* FALLTHROUGH */ diff --git a/src/include/cache.h b/src/include/cache.h index c8dd05a644b..4f7981a5df9 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -80,8 +80,10 @@ struct __wt_cache { uint64_t pages_dirty; uint64_t bytes_read; /* Bytes read into memory */ - uint64_t app_evicts; /* Pages evicted by user threads */ uint64_t app_waits; /* User threads waited for cache */ + uint64_t app_evicts; /* Pages evicted by user threads */ + uint64_t server_evicts; /* Pages evicted by server thread */ + uint64_t worker_evicts; /* Pages evicted by worker threads */ uint64_t evict_max_page_size; /* Largest page seen at eviction */ |