diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2018-09-19 14:39:09 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2020-01-05 14:16:52 -0600 |
commit | a59540132c14b3801234c8212718b3cf15f9bb44 (patch) | |
tree | 4336630e548e19e526717f41e2d8584ab93fcec9 | |
parent | b02599ed9f66004eac66c5129c4abd454f465217 (diff) | |
download | couchdb-a59540132c14b3801234c8212718b3cf15f9bb44.tar.gz |
Set a high priority on couch_server
In a VM with lots of processes couch_server can end up slowing down
purely to not being scheduled which in turn will cause its message queue
to backup. We've attempted this before but due to message passing have
never seen it have a significant effect. However, now that we're
actively avoiding synchronous message passing inside the man loop this
has a significant effect by being able to process messages as soon as it
has one in its mailbox.
-rw-r--r-- | rel/overlay/etc/default.ini | 5 | ||||
-rw-r--r-- | src/couch/src/couch_server.erl | 1 | ||||
-rw-r--r-- | src/couch/src/couch_util.erl | 11 |
3 files changed, 17 insertions, 0 deletions
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini index 9a8c70bc9..a1df0805a 100644 --- a/rel/overlay/etc/default.ini +++ b/rel/overlay/etc/default.ini @@ -93,6 +93,11 @@ users_db_security_editable = false ; having to ask every configured engine. couch = couch_bt_engine +[process_priority] +; Selectively disable altering process priorities +; for modules that request it. +; couch_server = true + [cluster] q=2 n=3 diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl index a72627b79..909e23898 100644 --- a/src/couch/src/couch_server.erl +++ b/src/couch/src/couch_server.erl @@ -235,6 +235,7 @@ close_db_if_idle(DbName) -> init([]) -> couch_util:set_mqd_off_heap(?MODULE), + couch_util:set_process_priority(?MODULE, high), % Mark pluggable storage engines as a supported feature config:enable_feature('pluggable-storage-engines'), diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl index e2885a15e..b5c93ce51 100644 --- a/src/couch/src/couch_util.erl +++ b/src/couch/src/couch_util.erl @@ -39,6 +39,7 @@ -export([check_config_blacklist/1]). -export([check_md5/2]). -export([set_mqd_off_heap/1]). +-export([set_process_priority/2]). -include_lib("couch/include/couch_db.hrl"). @@ -690,6 +691,16 @@ set_mqd_off_heap(Module) -> end. +set_process_priority(Module, Level) -> + case config:get_boolean("process_priority", atom_to_list(Module), true) of + true -> + process_flag(priority, Level), + ok; + false -> + ok + end. + + ensure_loaded(Module) when is_atom(Module) -> case code:ensure_loaded(Module) of {module, Module} -> |