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 2017/06/06 16:17:55 UTC

[couchdb] branch master updated: Allow configuration of max doc IDs for optimised code path in changes filter

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

vatamane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 42b3401  Allow configuration of max doc IDs for optimised code path in changes filter
42b3401 is described below

commit 42b34010841afe00596c579af346651b7202d963
Author: Alex Anderson <an...@medicmobile.org>
AuthorDate: Thu May 25 21:26:05 2017 +0000

    Allow configuration of max doc IDs for optimised code path in changes filter
    
    There are two implementations for filtering the _changes feed by doc_ids.  One
    implementation is faster, but requires more server resources.  The other is
    cheaper but very slow.  This commit allows configuration of the threshold at
    which couch changes to using the slower implementation using:
    
    	[couchdb]
    	changes_doc_ids_optimization_threshold = 100
    
    COUCHDB-3425
---
 rel/overlay/etc/default.ini     |  4 ++++
 src/couch/src/couch_changes.erl | 15 ++++++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 5dc4628..b92b1b7 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -35,6 +35,10 @@ default_security = admin_local
 ; stem_interactive_updates = true
 ; update_lru_on_read = true
 ; uri_file =
+; The speed of processing the _changes feed with doc_ids filter can be
+; influenced directly with this setting - increase for faster processing at the
+; expense of more memory usage.
+changes_doc_ids_optimization_threshold = 100
 
 [cluster]
 q=8
diff --git a/src/couch/src/couch_changes.erl b/src/couch/src/couch_changes.erl
index 52ff39d..835251d 100644
--- a/src/couch/src/couch_changes.erl
+++ b/src/couch/src/couch_changes.erl
@@ -29,10 +29,6 @@
 
 -export([changes_enumerator/2]).
 
-% For the builtin filter _docs_ids, this is the maximum number
-% of documents for which we trigger the optimized code path.
--define(MAX_DOC_IDS, 100).
-
 -record(changes_acc, {
     db,
     view_name,
@@ -556,9 +552,14 @@ send_changes(Acc, Dir, FirstRound) ->
     end.
 
 
-can_optimize(true, {doc_ids, _Style, DocIds})
-        when length(DocIds) =< ?MAX_DOC_IDS ->
-    {true, fun send_changes_doc_ids/6};
+can_optimize(true, {doc_ids, _Style, DocIds}) ->
+    MaxDocIds = config:get_integer("couchdb",
+        "changes_doc_ids_optimization_threshold", 100),
+    if length(DocIds) =< MaxDocIds ->
+        {true, fun send_changes_doc_ids/6};
+    true ->
+        false
+    end;
 can_optimize(true, {design_docs, _Style}) ->
     {true, fun send_changes_design_docs/6};
 can_optimize(_, _) ->

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].