You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2018/09/06 22:00:16 UTC

[couchdb] branch allow-disabling-off-heap-messages updated (3acd37e -> f29b09c)

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

vatamane pushed a change to branch allow-disabling-off-heap-messages
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    omit 3acd37e  Allow disabling off-heap messages
     new f29b09c  Allow disabling off-heap messages

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (3acd37e)
            \
             N -- N -- N   refs/heads/allow-disabling-off-heap-messages (f29b09c)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 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.


Summary of changes:
 src/couch/src/couch_server.erl         | 2 +-
 src/couch/src/couch_util.erl           | 6 +++---
 src/couch_log/src/couch_log_server.erl | 2 +-
 src/ddoc_cache/src/ddoc_cache_lru.erl  | 2 +-
 src/mem3/src/mem3_shards.erl           | 2 +-
 src/rexi/src/rexi_server.erl           | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)


[couchdb] 01/01: Allow disabling off-heap messages

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

vatamane pushed a commit to branch allow-disabling-off-heap-messages
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit f29b09cd73be92b79842469ca23f53829bed4901
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Sep 6 17:31:34 2018 -0400

    Allow disabling off-heap messages
    
    Off-heap messages is an Erlang 19 feature:
    
    http://erlang.org/doc/man/erlang.html#process_flag_message_queue_data
    
    It is adviseable to use that setting for processes which expect to receive a
    lot of messages. CouchDB sets it for couch_server, couch_log_server and bunch
    of others as well.
    
    In some cases the off-heap behavior could alter the timing of message receives
    and expose subtle bugs that have been lurking in the code for years. Or could
    slightly reduce performance, so a safety measure allow disabling it.
---
 src/couch/src/couch_server.erl         |  2 +-
 src/couch/src/couch_util.erl           | 19 ++++++++++++-------
 src/couch_log/src/couch_log_server.erl |  2 +-
 src/ddoc_cache/src/ddoc_cache_lru.erl  |  2 +-
 src/mem3/src/mem3_shards.erl           |  2 +-
 src/rexi/src/rexi_server.erl           |  2 +-
 6 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index 7210520..50c8cae 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/src/couch_server.erl
@@ -211,7 +211,7 @@ close_db_if_idle(DbName) ->
 
 
 init([]) ->
-    couch_util:set_mqd_off_heap(),
+    couch_util:set_mqd_off_heap(?MODULE),
 
     % 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 936b562..8f25edc 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -37,7 +37,7 @@
 -export([unique_monotonic_integer/0]).
 -export([check_config_blacklist/1]).
 -export([check_md5/2]).
--export([set_mqd_off_heap/0]).
+-export([set_mqd_off_heap/1]).
 
 -include_lib("couch/include/couch_db.hrl").
 
@@ -670,12 +670,17 @@ 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
+set_mqd_off_heap(Module) ->
+    case config:get_boolean("off_heap_mqd", atom_to_list(Module), true) of
+        true ->
+            try
+                erlang:process_flag(message_queue_data, off_heap),
+                ok
+            catch error:badarg ->
+                    ok
+            end;
+        false ->
+            ok
     end.
 
 
diff --git a/src/couch_log/src/couch_log_server.erl b/src/couch_log/src/couch_log_server.erl
index ea5def8..8432b9a 100644
--- a/src/couch_log/src/couch_log_server.erl
+++ b/src/couch_log/src/couch_log_server.erl
@@ -58,7 +58,7 @@ log(Entry) ->
 
 
 init(_) ->
-    couch_util:set_mqd_off_heap(),
+    couch_util:set_mqd_off_heap(?MODULE),
     process_flag(trap_exit, true),
     {ok, #st{
         writer = couch_log_writer:init()
diff --git a/src/ddoc_cache/src/ddoc_cache_lru.erl b/src/ddoc_cache/src/ddoc_cache_lru.erl
index 248a76d..28a8a64 100644
--- a/src/ddoc_cache/src/ddoc_cache_lru.erl
+++ b/src/ddoc_cache/src/ddoc_cache_lru.erl
@@ -87,7 +87,7 @@ refresh(DbName, DDocIds) ->
 
 
 init(_) ->
-    couch_util:set_mqd_off_heap(),
+    couch_util:set_mqd_off_heap(?MODULE),
     process_flag(trap_exit, true),
     BaseOpts = [public, named_table],
     CacheOpts = [
diff --git a/src/mem3/src/mem3_shards.erl b/src/mem3/src/mem3_shards.erl
index da3b69a..183f28f 100644
--- a/src/mem3/src/mem3_shards.erl
+++ b/src/mem3/src/mem3_shards.erl
@@ -184,7 +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(),
+    couch_util:set_mqd_off_heap(?MODULE),
     ets:new(?SHARDS, [
         bag,
         public,
diff --git a/src/rexi/src/rexi_server.erl b/src/rexi/src/rexi_server.erl
index 954ca88..58a510b 100644
--- a/src/rexi/src/rexi_server.erl
+++ b/src/rexi/src/rexi_server.erl
@@ -39,7 +39,7 @@ start_link(ServerId) ->
     gen_server:start_link({local, ServerId}, ?MODULE, [], []).
 
 init([]) ->
-    couch_util:set_mqd_off_heap(),
+    couch_util:set_mqd_off_heap(?MODULE),
     {ok, #st{}}.
 
 handle_call(get_errors, _From, #st{errors = Errors} = St) ->