Skip to content

Commit

Permalink
Added batching of multiple updating requests, to improve throughput w…
Browse files Browse the repository at this point in the history
…ith many writers. Also removed the couch_batch_save module, now batch requests are simply saved async as immediately, batching with outhr updates if possible.

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@832550 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Damien F. Katz committed Nov 3, 2009
1 parent f2689f9 commit 4387dc1
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 427 deletions.
2 changes: 1 addition & 1 deletion README
Expand Up @@ -452,7 +452,7 @@ Tests are also available to be run individually like such:
# Current time local 2009-09-26 23:47:44
# Using etap version "0.3.4"
1..39
ok 1 - Loaded: couch_batch_save
ok 1 - Loaded: couch_btree
...

Cryptographic Software Notice
Expand Down
1 change: 0 additions & 1 deletion etc/couchdb/default.ini.tpl.in
Expand Up @@ -48,7 +48,6 @@ reduce_limit = true
view_manager={couch_view, start_link, []}
external_manager={couch_external_manager, start_link, []}
db_update_notifier={couch_db_update_notifier_sup, start_link, []}
batch_save={couch_batch_save_sup, start_link, []}
query_servers={couch_query_servers, start_link, []}
httpd={couch_httpd, start_link, []}
stats_aggregator={couch_stats_aggregator, start, []}
Expand Down
61 changes: 23 additions & 38 deletions share/www/script/test/batch_save.js
Expand Up @@ -16,45 +16,30 @@ couchTests.batch_save = function(debug) {
db.createDb();
if (debug) debugger;

// commit should work fine with no batches
T(db.ensureFullCommit().ok);

// PUT a doc with ?batch=ok
T(db.save({_id:"0",a:1,b:1}, {batch : "ok"}).ok);

// test that response is 202 Accepted
T(db.last_req.status == 202);

T(db.allDocs().total_rows == 0);

restartServer();

// lost the updates
T(db.allDocs().total_rows == 0);

T(db.save({_id:"0",a:1,b:1}, {batch : "ok"}).ok);
T(db.save({_id:"1",a:1,b:1}, {batch : "ok"}).ok);
T(db.save({_id:"2",a:1,b:1}, {batch : "ok"}).ok);

T(db.ensureFullCommit().ok);
T(db.allDocs().total_rows == 3);
var i
for(i=0; i < 100; i++) {
T(db.save({_id:i.toString(),a:i,b:i}, {batch : "ok"}).ok);

// test that response is 202 Accepted
T(db.last_req.status == 202);
}

for(i=0; i < 100; i++) {
// attempt to save the same document a bunch of times
T(db.save({_id:"foo",a:i,b:i}, {batch : "ok"}).ok);

// test that response is 202 Accepted
T(db.last_req.status == 202);
}

while(db.allDocs().total_rows != 101){};

// repeat the tests for POST
var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
T(JSON.parse(resp.responseText).ok);

// test that response is 202 Accepted
T(resp.status == 202);

T(db.allDocs().total_rows == 3);
// restartServer();
// // lost the POSTed doc
// T(db.allDocs().total_rows == 3);

var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
T(JSON.parse(resp.responseText).ok);

T(db.ensureFullCommit().ok);
T(db.allDocs().total_rows == 5);
for(i=0; i < 100; i++) {
var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
T(JSON.parse(resp.responseText).ok);
}

while(db.allDocs().total_rows != 201){};

};
4 changes: 0 additions & 4 deletions src/couchdb/Makefile.am
Expand Up @@ -56,8 +56,6 @@ source_files = \
couch.erl \
couch_app.erl \
couch_btree.erl \
couch_batch_save.erl \
couch_batch_save_sup.erl \
couch_config.erl \
couch_config_writer.erl \
couch_db.erl \
Expand Down Expand Up @@ -113,8 +111,6 @@ compiled_files = \
couch.beam \
couch_app.beam \
couch_btree.beam \
couch_batch_save.beam \
couch_batch_save_sup.beam \
couch_config.beam \
couch_config_writer.beam \
couch_db.beam \
Expand Down
2 changes: 0 additions & 2 deletions src/couchdb/couch.app.tpl.in
Expand Up @@ -3,8 +3,6 @@
{vsn, "@version@"},
{modules, [@modules@]},
{registered, [
couch_batch_save,
couch_batch_save_sup,
couch_config,
couch_db_update,
couch_db_update_notifier_sup,
Expand Down
273 changes: 0 additions & 273 deletions src/couchdb/couch_batch_save.erl

This file was deleted.

0 comments on commit 4387dc1

Please sign in to comment.