You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2015/07/21 16:03:10 UTC
chttpd commit: updated refs/heads/2724-chunked-buffering to 9fcd5eb
Repository: couchdb-chttpd
Updated Branches:
refs/heads/2724-chunked-buffering 57a8dff89 -> 9fcd5eb73
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/9fcd5eb7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/9fcd5eb7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/9fcd5eb7
Branch: refs/heads/2724-chunked-buffering
Commit: 9fcd5eb7360f229017f01cf5f7b604d80f436428
Parents: 57a8dff
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Tue Jul 21 09:57:24 2015 -0400
Committer: Adam Kocoloski <ad...@cloudant.com>
Committed: Tue Jul 21 09:57:24 2015 -0400
----------------------------------------------------------------------
src/chttpd.erl | 16 ++++++++++++++++
src/chttpd_db.erl | 5 ++---
2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/9fcd5eb7/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/9fcd5eb7/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),