You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2018/06/18 17:41:24 UTC

[couchdb] branch add-set-mqd-off-heap created (now 8e6c8f7)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch add-set-mqd-off-heap
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 8e6c8f7  Call `set_mqd_off_heap` for critical processes

This branch includes the following new commits:

     new a5cd856  Add set_mqd_off_heap utility function
     new 8e6c8f7  Call `set_mqd_off_heap` for critical processes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
davisp@apache.org.

[couchdb] 02/02: Call `set_mqd_off_heap` for critical processes

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch add-set-mqd-off-heap
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 8e6c8f7f948cb73a47fb2b30fbcdec27ed881593
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jun 18 12:39:30 2018 -0500

    Call `set_mqd_off_heap` for critical processes
    
    This uses the new `couch_util:set_mqd_off_heap/0` function to set
    message queues to off_heap for some of our critical processes that
    receive a significant amount of load in terms of message volume.
---
 src/couch/src/couch_server.erl         | 2 ++
 src/couch_log/src/couch_log_server.erl | 1 +
 src/mem3/src/mem3_shards.erl           | 1 +
 src/rexi/src/rexi_server.erl           | 1 +
 4 files changed, 5 insertions(+)

diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index 05af0ed..903eb09 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/src/couch_server.erl
@@ -210,6 +210,8 @@ close_db_if_idle(DbName) ->
 
 
 init([]) ->
+    couch_util:set_mqd_off_heap(),
+
     % Mark pluggable storage engines as a supported feature
     config:enable_feature('pluggable-storage-engines'),
 
diff --git a/src/couch_log/src/couch_log_server.erl b/src/couch_log/src/couch_log_server.erl
index be44af8..ea5def8 100644
--- a/src/couch_log/src/couch_log_server.erl
+++ b/src/couch_log/src/couch_log_server.erl
@@ -58,6 +58,7 @@ log(Entry) ->
 
 
 init(_) ->
+    couch_util:set_mqd_off_heap(),
     process_flag(trap_exit, true),
     {ok, #st{
         writer = couch_log_writer:init()
diff --git a/src/mem3/src/mem3_shards.erl b/src/mem3/src/mem3_shards.erl
index c84b873..da3b69a 100644
--- a/src/mem3/src/mem3_shards.erl
+++ b/src/mem3/src/mem3_shards.erl
@@ -184,6 +184,7 @@ handle_config_terminate(_Server, _Reason, _State) ->
     erlang:send_after(?RELISTEN_DELAY, whereis(?MODULE), restart_config_listener).
 
 init([]) ->
+    couch_util:set_mqd_off_heap(),
     ets:new(?SHARDS, [
         bag,
         public,
diff --git a/src/rexi/src/rexi_server.erl b/src/rexi/src/rexi_server.erl
index 3d3f272..954ca88 100644
--- a/src/rexi/src/rexi_server.erl
+++ b/src/rexi/src/rexi_server.erl
@@ -39,6 +39,7 @@ start_link(ServerId) ->
     gen_server:start_link({local, ServerId}, ?MODULE, [], []).
 
 init([]) ->
+    couch_util:set_mqd_off_heap(),
     {ok, #st{}}.
 
 handle_call(get_errors, _From, #st{errors = Errors} = St) ->

-- 
To stop receiving notification emails like this one, please contact
davisp@apache.org.

[couchdb] 01/02: Add set_mqd_off_heap utility function

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch add-set-mqd-off-heap
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit a5cd85672466554ac27c41857a6ca1252b43db91
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jun 18 12:34:02 2018 -0500

    Add set_mqd_off_heap utility function
    
    In Erlang VMs starting with version 19.0 have a new process_flag to
    store messages off the process heap. This is extremely useful for
    processes that can have huge numbers of messages in their mailbox. For
    CouchDB this is most usually observed when couch_server backs up with a
    large message queue which wedges the entire node.
    
    This utility function will set a process's message_queue_data flag to
    off_heap in a way that doesn't break builds of CouchDB on older Erlang
    VMs while automatically enabling the flag on VMs that do support it.
---
 src/couch/src/couch_util.erl | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index f3a9249..af1c0ef 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -37,6 +37,7 @@
 -export([unique_monotonic_integer/0]).
 -export([check_config_blacklist/1]).
 -export([check_md5/2]).
+-export([set_mqd_off_heap/0]).
 
 -include_lib("couch/include/couch_db.hrl").
 
@@ -639,6 +640,15 @@ check_md5(Sig, Sig) -> ok;
 check_md5(_, _) -> throw(md5_mismatch).
 
 
+set_mqd_off_heap() ->
+    try
+        erlang:process_flag(message_queue_data, off_heap),
+        ok
+    catch error:badarg ->
+        ok
+    end.
+
+
 ensure_loaded(Module) when is_atom(Module) ->
     case code:ensure_loaded(Module) of
     {module, Module} ->

-- 
To stop receiving notification emails like this one, please contact
davisp@apache.org.