diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/conn/conn_cache.c')
-rw-r--r-- | src/third_party/wiredtiger/src/conn/conn_cache.c | 104 |
1 files changed, 70 insertions, 34 deletions
diff --git a/src/third_party/wiredtiger/src/conn/conn_cache.c b/src/third_party/wiredtiger/src/conn/conn_cache.c index 9f15db5382b..7e94e9e87dc 100644 --- a/src/third_party/wiredtiger/src/conn/conn_cache.c +++ b/src/third_party/wiredtiger/src/conn/conn_cache.c @@ -18,7 +18,7 @@ __cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[]) WT_CACHE *cache; WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; - uint32_t evict_workers_max, evict_workers_min; + uint32_t evict_threads_max, evict_threads_min; conn = S2C(session); cache = conn->cache; @@ -42,31 +42,48 @@ __cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[]) WT_RET(__wt_config_gets(session, cfg, "eviction_trigger", &cval)); cache->eviction_trigger = (u_int)cval.val; - WT_RET(__wt_config_gets(session, cfg, "eviction_dirty_target", &cval)); - cache->eviction_dirty_target = (u_int)cval.val; + if (F_ISSET(conn, WT_CONN_IN_MEMORY)) + cache->eviction_checkpoint_target = + cache->eviction_dirty_target = + cache->eviction_dirty_trigger = 100U; + else { + WT_RET(__wt_config_gets( + session, cfg, "eviction_checkpoint_target", &cval)); + cache->eviction_checkpoint_target = (u_int)cval.val; - WT_RET(__wt_config_gets(session, cfg, "eviction_dirty_trigger", &cval)); - cache->eviction_dirty_trigger = (u_int)cval.val; + WT_RET(__wt_config_gets( + session, cfg, "eviction_dirty_target", &cval)); + cache->eviction_dirty_target = (u_int)cval.val; + + /* + * Sanity check the checkpoint target: don't allow a value + * lower than the dirty target. + */ + if (cache->eviction_checkpoint_target > 0 && + cache->eviction_checkpoint_target < + cache->eviction_dirty_target) + cache->eviction_checkpoint_target = + cache->eviction_dirty_target; + + WT_RET(__wt_config_gets( + session, cfg, "eviction_dirty_trigger", &cval)); + cache->eviction_dirty_trigger = (u_int)cval.val; + } - /* - * The eviction thread configuration options include the main eviction - * thread and workers. Our implementation splits them out. Adjust for - * the difference when parsing the configuration. - */ WT_RET(__wt_config_gets(session, cfg, "eviction.threads_max", &cval)); WT_ASSERT(session, cval.val > 0); - evict_workers_max = (uint32_t)cval.val - 1; + evict_threads_max = (uint32_t)cval.val; WT_RET(__wt_config_gets(session, cfg, "eviction.threads_min", &cval)); WT_ASSERT(session, cval.val > 0); - evict_workers_min = (uint32_t)cval.val - 1; + evict_threads_min = (uint32_t)cval.val; - if (evict_workers_min > evict_workers_max) + if (evict_threads_min > evict_threads_max) WT_RET_MSG(session, EINVAL, "eviction=(threads_min) cannot be greater than " "eviction=(threads_max)"); - conn->evict_workers_max = evict_workers_max; - conn->evict_workers_min = evict_workers_min; + conn->evict_threads_max = evict_threads_max; + conn->evict_threads_min = evict_threads_min; return (0); } @@ -114,6 +131,16 @@ __wt_cache_config(WT_SESSION_IMPL *session, bool reconfigure, const char *cfg[]) WT_RET(__wt_conn_cache_pool_open(session)); } + /* + * Resize the thread group if reconfiguring, otherwise the thread group + * will be initialized as part of creating the cache. + */ + if (reconfigure) + WT_RET(__wt_thread_group_resize( + session, &conn->evict_threads, + conn->evict_threads_min, conn->evict_threads_max, + WT_THREAD_CAN_WAIT | WT_THREAD_PANIC_FAIL)); + return (0); } @@ -156,8 +183,6 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]) WT_ERR(__wt_cond_auto_alloc(session, "cache eviction server", false, 10000, WT_MILLION, &cache->evict_cond)); - WT_ERR(__wt_cond_alloc(session, - "eviction waiters", false, &cache->evict_waiter_cond)); WT_ERR(__wt_spin_init(session, &cache->evict_pass_lock, "evict pass")); WT_ERR(__wt_spin_init(session, &cache->evict_queue_lock, "cache eviction queue")); @@ -176,6 +201,12 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]) &cache->evict_queues[i].evict_lock, "cache eviction")); } + /* Ensure there are always non-NULL queues. */ + cache->evict_current_queue = cache->evict_fill_queue = + &cache->evict_queues[0]; + cache->evict_other_queue = &cache->evict_queues[1]; + cache->evict_urgent_queue = &cache->evict_queues[WT_EVICT_URGENT_QUEUE]; + /* * We get/set some values in the cache statistics (rather than have * two copies), configure them. @@ -197,7 +228,7 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session) WT_CACHE *cache; WT_CONNECTION_IMPL *conn; WT_CONNECTION_STATS **stats; - uint64_t inuse, leaf, used; + uint64_t inuse, leaf; conn = S2C(session); cache = conn->cache; @@ -208,34 +239,37 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session) * There are races updating the different cache tracking values so * be paranoid calculating the leaf byte usage. */ - used = cache->bytes_overflow + cache->bytes_internal; - leaf = inuse > used ? inuse - used : 0; + leaf = inuse > cache->bytes_internal ? + inuse - cache->bytes_internal : 0; 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_overhead, cache->overhead_pct); - WT_STAT_SET( - session, stats, cache_pages_inuse, __wt_cache_pages_inuse(cache)); + WT_STAT_SET( session, stats, cache_bytes_dirty, __wt_cache_dirty_inuse(cache)); - WT_STAT_SET(session, stats, - cache_eviction_maximum_page_size, cache->evict_max_page_size); - WT_STAT_SET(session, stats, cache_pages_dirty, cache->pages_dirty); - WT_STAT_SET( - session, stats, cache_bytes_internal, cache->bytes_internal); + session, stats, cache_bytes_image, __wt_cache_bytes_image(cache)); + WT_STAT_SET( + session, stats, cache_pages_inuse, __wt_cache_pages_inuse(cache)); WT_STAT_SET( - session, stats, cache_bytes_overflow, cache->bytes_overflow); + session, stats, cache_bytes_internal, cache->bytes_internal); WT_STAT_SET(session, stats, cache_bytes_leaf, leaf); + WT_STAT_SET( + session, stats, cache_bytes_other, __wt_cache_bytes_other(cache)); + + WT_STAT_SET(session, stats, + cache_eviction_maximum_page_size, cache->evict_max_page_size); + WT_STAT_SET(session, stats, cache_pages_dirty, + cache->pages_dirty_intl + cache->pages_dirty_leaf); /* * The number of files with active walks ~= number of hazard pointers * in the walk session. Note: reading without locking. */ - if (conn->evict_session != NULL) + if (conn->evict_server_running) WT_STAT_SET(session, stats, cache_eviction_walks_active, - conn->evict_session->nhazard); + cache->walk_session->nhazard); } /* @@ -267,14 +301,15 @@ __wt_cache_destroy(WT_SESSION_IMPL *session) __wt_errx(session, "cache server: exiting with %" PRIu64 " bytes in memory", cache->bytes_inmem); - if (cache->bytes_dirty != 0 || cache->pages_dirty != 0) + if (cache->bytes_dirty_intl + cache->bytes_dirty_leaf != 0 || + cache->pages_dirty_intl + cache->pages_dirty_leaf != 0) __wt_errx(session, "cache server: exiting with %" PRIu64 " bytes dirty and %" PRIu64 " pages dirty", - cache->bytes_dirty, cache->pages_dirty); + cache->bytes_dirty_intl + cache->bytes_dirty_leaf, + cache->pages_dirty_intl + cache->pages_dirty_leaf); WT_TRET(__wt_cond_auto_destroy(session, &cache->evict_cond)); - WT_TRET(__wt_cond_destroy(session, &cache->evict_waiter_cond)); __wt_spin_destroy(session, &cache->evict_pass_lock); __wt_spin_destroy(session, &cache->evict_queue_lock); __wt_spin_destroy(session, &cache->evict_walk_lock); @@ -286,6 +321,7 @@ __wt_cache_destroy(WT_SESSION_IMPL *session) __wt_spin_destroy(session, &cache->evict_queues[i].evict_lock); __wt_free(session, cache->evict_queues[i].evict_queue); } + __wt_free(session, conn->cache); return (ret); } |