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:25 UTC

[couchdb] 01/02: Add set_mqd_off_heap utility function

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.