couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject chttpd commit: updated refs/heads/2724-chunked-buffering to a077bcf
Date Tue, 21 Jul 2015 14:25:20 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/2724-chunked-buffering 9fcd5eb73 -> a077bcf8a (forced update)


Define an accessor for the chunk buffer config val


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/a077bcf8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/a077bcf8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/a077bcf8

Branch: refs/heads/2724-chunked-buffering
Commit: a077bcf8a4886325e362a7e35a1fe2cb30695135
Parents: 57a8dff
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Tue Jul 21 09:57:24 2015 -0400
Committer: Adam Kocoloski <adam@cloudant.com>
Committed: Tue Jul 21 10:25:08 2015 -0400

----------------------------------------------------------------------
 src/chttpd.erl      | 16 ++++++++++++++++
 src/chttpd_db.erl   |  5 ++---
 src/chttpd_view.erl |  2 +-
 3 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/a077bcf8/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index f6ce530..c51a463 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -34,6 +34,10 @@
     send_delayed_error/2, end_delayed_json_response/1,
     get_delayed_req/1]).
 
+-export([
+    chunked_response_buffer_size/0
+]).
+
 -record(delayed_resp, {
     start_fun,
     req,
@@ -994,3 +998,15 @@ stack_hash(Stack) ->
 
 with_default(undefined, Default) -> Default;
 with_default(Value, _) -> Value.
+
+%% @doc CouchDB uses a chunked transfer-encoding to stream responses to
+%% _all_docs, _changes, _view and other similar requests. This configuration
+%% value sets the maximum size of a chunk; the system will buffer rows in the
+%% response until it reaches this threshold and then send all the rows in one
+%% chunk to improve network efficiency. The default value is chosen so that
+%% the assembled chunk fits into the default Ethernet frame size (some reserved
+%% padding is necessary to accomodate the reporting of the chunk length). Set
+%% this value to 0 to restore the older behavior of sending each row in a
+%% dedicated chunk.
+chunked_response_buffer_size() ->
+    config:get_integer("httpd", "chunked_response_buffer", 1490).

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/a077bcf8/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index ea3879f..329217a 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -86,8 +86,7 @@ handle_changes_req1(#httpd{}=Req, Db) ->
     ChangesArgs = Args0#changes_args{
         filter_fun = couch_changes:configure_filter(Raw, Style, Req, Db)
     },
-    % Default to ~filling the payload of a standard Ethernet frame
-    Max = config:get_integer("httpd", "chunked_response_buffer", 1490),
+    Max = chttpd:chunked_response_buffer_size(),
     case ChangesArgs#changes_args.feed of
     "normal" ->
         T0 = os:timestamp(),
@@ -604,7 +603,7 @@ all_docs_view(Req, Db, Keys, OP) ->
     Args = Args3#mrargs{preflight_fun=ETagFun},
     Options = [{user_ctx, Req#httpd.user_ctx}],
     {ok, Resp} = couch_httpd:etag_maybe(Req, fun() ->
-        Max = config:get_integer("httpd", "chunked_response_buffer", 1490),
+        Max = chttpd:chunked_response_buffer_size(),
         VAcc0 = #vacc{db=Db, req=Req, threshold=Max},
         fabric:all_docs(Db, Options, fun couch_mrview_http:view_cb/2, VAcc0, Args)
     end),

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/a077bcf8/src/chttpd_view.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_view.erl b/src/chttpd_view.erl
index 009aa8f..bb98fec 100644
--- a/src/chttpd_view.erl
+++ b/src/chttpd_view.erl
@@ -53,7 +53,7 @@ design_doc_view(Req, Db, DDoc, ViewName, Keys) ->
     end,
     Args = Args0#mrargs{preflight_fun=ETagFun},
     {ok, Resp} = couch_httpd:etag_maybe(Req, fun() ->
-        Max = config:get_integer("httpd", "chunked_response_buffer", 1490),
+        Max = chttpd:chunked_response_buffer_size(),
         VAcc0 = #vacc{db=Db, req=Req, threshold=Max},
         fabric:query_view(Db, DDoc, ViewName, fun couch_mrview_http:view_cb/2, VAcc0, Args)
     end),


Mime
View raw message