summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-08-11 02:34:00 +0000
committerAlex Gorrod <alexg@wiredtiger.com>2014-08-11 02:34:00 +0000
commit7ccec49258ae36a6c0eee2fa850b416f88c025b4 (patch)
treeee9798ebe18c424a86a3a923d001a0e1120e2830
parent2a4554b3c39a2ca7ec7f1115a3c0809082917669 (diff)
downloadmongo-7ccec49258ae36a6c0eee2fa850b416f88c025b4.tar.gz
Make dynamic eviction workers the default. #1143
-rw-r--r--dist/api_data.py15
-rw-r--r--src/btree/bt_evict.c21
-rw-r--r--src/config/config_def.c32
-rw-r--r--src/conn/conn_cache.c21
-rw-r--r--src/include/connection.h1
-rw-r--r--src/include/wiredtiger.in24
6 files changed, 83 insertions, 31 deletions
diff --git a/dist/api_data.py b/dist/api_data.py
index 30c76d26a84..3f0fabdc3b9 100644
--- a/dist/api_data.py
+++ b/dist/api_data.py
@@ -340,11 +340,16 @@ connection_runtime_config = [
Config('eviction_trigger', '95', r'''
trigger eviction when the cache is using this much memory, as a
percentage of the total cache size''', min=10, max=99),
- Config('eviction_worker_max', '0', r'''
- maximum number of additional threads WiredTiger will start to help
- evict pages from cache. The number of threads currently running
- will vary depending on the current eviction load''',
- min=0, max=20),
+ Config('eviction_thread_max', '3', r'''
+ maximum number of threads WiredTiger will start to help
+ evict pages from cache. The number of threads currently running
+ will vary depending on the current eviction load''',
+ min=1, max=20),
+ Config('eviction_thread_min', '1', r'''
+ minimum number of threads WiredTiger will start to help evict
+ pages from cache. The number of threads currently running will
+ vary depending on the current eviction load''',
+ min=1, max=20),
Config('shared_cache', '', r'''
shared cache configuration options. A database should configure
either a cache_size or a shared_cache not both''',
diff --git a/src/btree/bt_evict.c b/src/btree/bt_evict.c
index 1cbd100df5a..e360981188b 100644
--- a/src/btree/bt_evict.c
+++ b/src/btree/bt_evict.c
@@ -168,12 +168,25 @@ __evict_server(void *arg)
* If we have caught up and there are more than the minimum
* number of eviction workers running, shut one down.
*/
- if (conn->evict_workers > 2) {
+ if (conn->evict_workers > conn->evict_workers_min) {
+ WT_TRET(__wt_verbose(session, WT_VERB_EVICTSERVER,
+ "Stopping evict worker: %"PRIu32"\n",
+ conn->evict_workers));
worker = &conn->evict_workctx[--conn->evict_workers];
F_CLR(worker, WT_EVICT_WORKER_RUN);
WT_TRET(__wt_cond_signal(
session, cache->evict_waiter_cond));
WT_TRET(__wt_thread_join(session, worker->tid));
+ /*
+ * Flag errors here with a message, but don't shut down
+ * the eviction server - that's fatal.
+ */
+ WT_ASSERT(session, ret == 0);
+ if (ret != 0) {
+ (void)__wt_msg(session,
+ "Error stopping eviction worker: %d", ret);
+ ret = 0;
+ }
}
F_CLR(cache, WT_EVICT_ACTIVE);
WT_ERR(__wt_verbose(session, WT_VERB_EVICTSERVER, "sleeping"));
@@ -238,8 +251,7 @@ __wt_evict_create(WT_CONNECTION_IMPL *conn)
WT_RET(__wt_open_internal_session(conn,
"eviction-worker", 0, 0, &workers[i].session));
workers[i].id = i;
- /* Start at most two worker threads initially. */
- if (i < 2) {
+ if (i < conn->evict_workers_min) {
++conn->evict_workers;
F_SET(&workers[i], WT_EVICT_WORKER_RUN);
WT_RET(__wt_thread_create(
@@ -433,6 +445,9 @@ __evict_pass(WT_SESSION_IMPL *session)
/* Start a worker if we have capacity and the cache is full. */
if (bytes_inuse > conn->cache_size &&
conn->evict_workers < conn->evict_workers_max) {
+ WT_RET(__wt_verbose(session, WT_VERB_EVICTSERVER,
+ "Starting evict worker: %"PRIu32"\n",
+ conn->evict_workers));
worker = &conn->evict_workctx[conn->evict_workers++];
F_SET(worker, WT_EVICT_WORKER_RUN);
WT_RET(__wt_thread_create(session,
diff --git a/src/config/config_def.c b/src/config/config_def.c
index 74bad4c6375..1b688384286 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -74,8 +74,9 @@ static const WT_CONFIG_CHECK confchk_connection_reconfigure[] = {
{ "error_prefix", "string", NULL, NULL },
{ "eviction_dirty_target", "int", "min=10,max=99", NULL },
{ "eviction_target", "int", "min=10,max=99", NULL },
+ { "eviction_thread_max", "int", "min=1,max=20", NULL },
+ { "eviction_thread_min", "int", "min=1,max=20", NULL },
{ "eviction_trigger", "int", "min=10,max=99", NULL },
- { "eviction_worker_max", "int", "min=0,max=20", NULL },
{ "shared_cache", "category", NULL,
confchk_shared_cache_subconfigs },
{ "statistics", "list",
@@ -298,8 +299,9 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open[] = {
{ "error_prefix", "string", NULL, NULL },
{ "eviction_dirty_target", "int", "min=10,max=99", NULL },
{ "eviction_target", "int", "min=10,max=99", NULL },
+ { "eviction_thread_max", "int", "min=1,max=20", NULL },
+ { "eviction_thread_min", "int", "min=1,max=20", NULL },
{ "eviction_trigger", "int", "min=10,max=99", NULL },
- { "eviction_worker_max", "int", "min=0,max=20", NULL },
{ "exclusive", "boolean", NULL, NULL },
{ "extensions", "list", NULL, NULL },
{ "file_extend", "list", "choices=[\"data\",\"log\"]", NULL },
@@ -370,9 +372,10 @@ static const WT_CONFIG_ENTRY config_entries[] = {
{ "connection.reconfigure",
"async=(enabled=0,ops_max=1024,threads=2),cache_size=100MB,"
"checkpoint=(name=\"WiredTigerCheckpoint\",wait=0),error_prefix=,"
- "eviction_dirty_target=80,eviction_target=80,eviction_trigger=95,"
- "eviction_worker_max=0,shared_cache=(chunk=10MB,name=,reserve=0,"
- "size=500MB),statistics=none,statistics_log=(on_close=0,"
+ "eviction_dirty_target=80,eviction_target=80,"
+ "eviction_thread_max=3,eviction_thread_min=1,eviction_trigger=95,"
+ "shared_cache=(chunk=10MB,name=,reserve=0,size=500MB),"
+ "statistics=none,statistics_log=(on_close=0,"
"path=\"WiredTigerStat.%d.%H\",sources=,"
"timestamp=\"%b %d %H:%M:%S\",wait=0),verbose=",
confchk_connection_reconfigure
@@ -480,15 +483,16 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"async=(enabled=0,ops_max=1024,threads=2),buffer_alignment=-1,"
"cache_size=100MB,checkpoint=(name=\"WiredTigerCheckpoint\","
"wait=0),checkpoint_sync=,create=0,direct_io=,error_prefix=,"
- "eviction_dirty_target=80,eviction_target=80,eviction_trigger=95,"
- "eviction_worker_max=0,exclusive=0,extensions=,file_extend=,"
- "hazard_max=1000,log=(archive=,enabled=0,file_max=100MB,"
- "path=\"\"),lsm_merge=,mmap=,multiprocess=0,session_max=100,"
- "shared_cache=(chunk=10MB,name=,reserve=0,size=500MB),"
- "statistics=none,statistics_log=(on_close=0,"
- "path=\"WiredTigerStat.%d.%H\",sources=,"
- "timestamp=\"%b %d %H:%M:%S\",wait=0),transaction_sync=(enabled=0"
- ",method=fsync),use_environment_priv=0,verbose=",
+ "eviction_dirty_target=80,eviction_target=80,"
+ "eviction_thread_max=3,eviction_thread_min=1,eviction_trigger=95,"
+ "exclusive=0,extensions=,file_extend=,hazard_max=1000,"
+ "log=(archive=,enabled=0,file_max=100MB,path=\"\"),lsm_merge=,"
+ "mmap=,multiprocess=0,session_max=100,shared_cache=(chunk=10MB,"
+ "name=,reserve=0,size=500MB),statistics=none,"
+ "statistics_log=(on_close=0,path=\"WiredTigerStat.%d.%H\","
+ "sources=,timestamp=\"%b %d %H:%M:%S\",wait=0),"
+ "transaction_sync=(enabled=0,method=fsync),use_environment_priv=0"
+ ",verbose=",
confchk_wiredtiger_open
},
{ NULL, NULL, NULL }
diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c
index d39a8f891d6..746df68758f 100644
--- a/src/conn/conn_cache.c
+++ b/src/conn/conn_cache.c
@@ -55,9 +55,28 @@ __wt_cache_config(WT_CONNECTION_IMPL *conn, const char *cfg[])
WT_RET_NOTFOUND_OK(ret);
if ((ret =
- __wt_config_gets(session, cfg, "eviction_worker_max", &cval)) == 0)
+ __wt_config_gets(session, cfg, "eviction_thread_max", &cval)) == 0)
conn->evict_workers_max = (u_int)cval.val;
WT_RET_NOTFOUND_OK(ret);
+ if ((ret =
+ __wt_config_gets(session, cfg, "eviction_thread_min", &cval)) == 0)
+ conn->evict_workers_min = (u_int)cval.val;
+ WT_RET_NOTFOUND_OK(ret);
+
+ if (conn->evict_workers_min > conn->evict_workers_max)
+ WT_RET_MSG(session, EINVAL,
+ "eviction_thread_min cannot be greater than "
+ "eviction_thread_max");
+
+ /*
+ * The eviction thread configuration options include the main eviction
+ * thread and workers. Our implementation splits them out. Adjust
+ * for that here.
+ */
+ WT_ASSERT(session,
+ conn->evict_workers_max > 0 && conn->evict_workers_min > 0);
+ conn->evict_workers_max--;
+ conn->evict_workers_min--;
return (0);
}
diff --git a/src/include/connection.h b/src/include/connection.h
index 96c26097045..b07ece5a9aa 100644
--- a/src/include/connection.h
+++ b/src/include/connection.h
@@ -204,6 +204,7 @@ struct __wt_connection_impl {
int evict_tid_set; /* Eviction server thread ID set */
uint32_t evict_workers_max;/* Max eviction workers */
+ uint32_t evict_workers_min;/* Min eviction workers */
uint32_t evict_workers; /* Number of eviction workers */
WT_EVICT_WORKER *evict_workctx; /* Eviction worker context */
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 0b93181e01c..fb04c4743d4 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -1526,13 +1526,17 @@ struct __wt_connection {
* total memory than the value\, as a percentage of the total cache
* size. Must be less than \c eviction_trigger., an integer between 10
* and 99; default \c 80.}
+ * @config{eviction_thread_max, maximum number of threads WiredTiger
+ * will start to help evict pages from cache. The number of threads
+ * currently running will vary depending on the current eviction load.,
+ * an integer between 1 and 20; default \c 3.}
+ * @config{eviction_thread_min, minimum number of threads WiredTiger
+ * will start to help evict pages from cache. The number of threads
+ * currently running will vary depending on the current eviction load.,
+ * an integer between 1 and 20; default \c 1.}
* @config{eviction_trigger, trigger eviction when the cache is using
* this much memory\, as a percentage of the total cache size., an
* integer between 10 and 99; default \c 95.}
- * @config{eviction_worker_max, maximum number of additional threads
- * WiredTiger will start to help evict pages from cache. The number of
- * threads currently running will vary depending on the current eviction
- * load., an integer between 0 and 20; default \c 0.}
* @config{shared_cache = (, shared cache configuration options. A
* database should configure either a cache_size or a shared_cache not
* both., a set of related configuration options defined below.}
@@ -1842,13 +1846,17 @@ struct __wt_connection {
* @config{eviction_target, continue evicting until the cache has less total
* memory than the value\, as a percentage of the total cache size. Must be
* less than \c eviction_trigger., an integer between 10 and 99; default \c 80.}
+ * @config{eviction_thread_max, maximum number of threads WiredTiger will start
+ * to help evict pages from cache. The number of threads currently running will
+ * vary depending on the current eviction load., an integer between 1 and 20;
+ * default \c 3.}
+ * @config{eviction_thread_min, minimum number of threads WiredTiger will start
+ * to help evict pages from cache. The number of threads currently running will
+ * vary depending on the current eviction load., an integer between 1 and 20;
+ * default \c 1.}
* @config{eviction_trigger, trigger eviction when the cache is using this much
* memory\, as a percentage of the total cache size., an integer between 10 and
* 99; default \c 95.}
- * @config{eviction_worker_max, maximum number of additional threads WiredTiger
- * will start to help evict pages from cache. The number of threads currently
- * running will vary depending on the current eviction load., an integer between
- * 0 and 20; default \c 0.}
* @config{exclusive, fail if the database already exists\, generally used with
* the \c create option., a boolean flag; default \c false.}
* @config{extensions, list of shared library extensions to load (using dlopen).