Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b8f806e417
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 205 lines (175 sloc) 10.826 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
Databases with 1 million documents each with a size of 4Kb
The databases have the following design document:

{
    "_id": "_design/test",
    "language": "javascript",
    "views": {
        "simple": {
            "map": "function(doc) { emit(doc.data5.float1, [doc.strings[2], doc.strings[10]]); }"
        }
    }
}


* trunk *

database file size after compaction: 7.5 Gb
view index file size after compaction: 257 Mb

** Before JSON nif:
$ time curl 'http://localhost:5985/trunk_db_1m/_design/test/_view/simple?limit=1'
{"total_rows":1000000,"offset":0,"rows":[
{"id":"00000632-d25d-49c6-9b4e-e038b78ff97d","key":76.572,"value":["jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9","fKYYthv8iFvaYoFoYZyB"]}
]}

real 58m28.599s
user 0m0.036s
sys 0m0.056s

** After JSON nif:
fdmanana 12:45:55 /opt/couchdb > time curl 'http://localhost:5985/trunk_db_1m/_design/test/_view/simple?limit=1'
{"total_rows":1000000,"offset":0,"rows":[
{"id":"00000632-d25d-49c6-9b4e-e038b78ff97d","key":76.572,"value":["jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9","fKYYthv8iFvaYoFoYZyB"]}
]}

real 51m14.738s
user 0m0.040s
sys 0m0.044s



* snappy branch *

database file size after compaction: 3.2 Gb
view index file size after compaction: 100 Mb

** Before JSON nif:
$ time curl 'http://localhost:5984/snappy_db_1m/_design/test/_view/simple?limit=1'
{"total_rows":1000000,"offset":0,"rows":[
{"id":"00000632-d25d-49c6-9b4e-e038b78ff97d","key":76.572,"value":["jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9","fKYYthv8iFvaYoFoYZyB"]}
]}

real 32m29.854s
user 0m0.008s
sys 0m0.052s

** After JSON nif:
fdmanana 15:40:39 /opt/couchdb > time curl 'http://localhost:5984/snappy_db_1m/_design/test/_view/simple?limit=1'
{"total_rows":1000000,"offset":0,"rows":[
{"id":"00000632-d25d-49c6-9b4e-e038b78ff97d","key":76.572,"value":["jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9","fKYYthv8iFvaYoFoYZyB"]}
]}

real 18m39.240s
user 0m0.012s
sys 0m0.020s



writes relaximation test: http://graphs.mikeal.couchone.com/#/graph/698bf36b6c64dbd19aa2bef63405480d



Erlang R14B02 (erts-5.8.3) [source] [smp:2:2] [rq:2] [async-threads:4] [hipe] [kernel-poll:true]

Eshell V5.8.3 (abort with ^G)
1> Apache CouchDB 1.2.0a7a6f6ee-git (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.37.0>] Apache CouchDB has started on http://127.0.0.1:5984/

1> rr("src/couchdb/couch_db.hrl").
[att,btree,changes_args,db,db_header,doc,doc_info,
 extern_resp_args,full_doc_info,group,httpd,index_header,
 reduce_fold_helper_funs,rev_info,user_ctx,view,
 view_fold_helper_funs,view_query_args]
2> {ok, Db} = couch_db:open_int(<<"large1kb">>, []).
{ok,#db{main_pid = <0.179.0>,update_pid = <0.180.0>,
        compactor_pid = nil,
        instance_start_time = <<"1301861125471547">>,fd = <0.181.0>,
        updater_fd = <0.177.0>,fd_ref_counter = <0.183.0>,
        header = #db_header{disk_version = 5,update_seq = 341301,
                            unused = 0,
                            fulldocinfo_by_id_btree_state = {480339898,{341298,0}},
                            docinfo_by_seq_btree_state = {480336370,341298},
                            local_docs_btree_state = {480317540,[]},
                            purge_seq = 1,purged_docs = 480340016,
                            security_ptr = 480321636,revs_limit = 1000},
        committed_update_seq = 341301,
        fulldocinfo_by_id_btree = #btree{fd = <0.177.0>,
                                         root = {480339898,{341298,0}},
                                         extract_kv = #Fun<couch_db_updater.10.91297870>,
                                         assemble_kv = #Fun<couch_db_updater.11.29248762>,
                                         less = #Fun<couch_btree.5.3534514>,
                                         reduce = #Fun<couch_db_updater.12.101621643>},
        docinfo_by_seq_btree = #btree{fd = <0.177.0>,
                                      root = {480336370,341298},
                                      extract_kv = #Fun<couch_db_updater.13.112240718>,
                                      assemble_kv = #Fun<couch_db_updater.14.90543234>,
                                      less = #Fun<couch_btree.5.3534514>,
                                      reduce = #Fun<couch_db_updater.15.111854220>},
        local_docs_btree = #btree{fd = <0.177.0>,
                                  root = {480317540,[]},
                                  extract_kv = #Fun<couch_btree.0.8709291>,
                                  assemble_kv = #Fun<couch_btree.1.100429438>,
                                  less = #Fun<couch_btree.2.3534514>,reduce = nil},
        update_seq = 341301,name = <<"large1kb">>,
        filepath = "/home/fdmanana/git/hub/couchdb/tmp/lib/large1kb.couch",
        validate_doc_funs = [],
        security = [{<<"admins">>,
                     {[{<<"names">>,[]},{<<"roles">>,[<<...>>|...]}]}},
                    {<<"members">>,{[{<<"names">>,[]},{<<"role"...>>,[]}]}}],
        security_ptr = 480321636,
        user_ctx = #user_ctx{name = null,roles = [],
                             handler = undefined},
        waiting_delayed_commit = nil,revs_limit = 1000,
        fsync_options = [before_header,after_header,on_file_open],
        options = []}}
3>
3> HBin = term_to_binary(Db#db.header).
<<131,104,11,100,0,9,100,98,95,104,101,97,100,101,114,97,
  5,98,0,5,53,53,97,0,104,2,98,28,161,...>>
4> byte_size(HBin).
77
5> byte_size(element(2, snappy:compress(HBin))).
69
6> byte_size(element(2, snappy:compress(HBin))).
69
7> {ok, Root} = couch_file:pread_binary(Db#db.fd, 480339898).
{ok,<<131,104,2,100,0,7,107,112,95,110,111,100,101,108,0,
      0,0,3,104,2,109,0,0,0,9,100,111,...>>}
8> RootBin = term_to_binary(Root).
<<131,109,0,0,0,114,131,104,2,100,0,7,107,112,95,110,111,
  100,101,108,0,0,0,3,104,2,109,0,0,...>>
9> byte_size(RootBin).
120
10> byte_size(element(2, snappy:compress(RootBin))).
104
11> SecBin = term_to_binary(Db#db.security).
<<131,108,0,0,0,2,104,2,109,0,0,0,6,97,100,109,105,110,
  115,104,1,108,0,0,0,2,104,2,109,...>>
12> byte_size(SecBin).
127
13> byte_size(element(2, snappy:compress(SecBin))).
80
14> {ok, Doc4Json} = file:read_file("../seatoncouch/doc_4k.json").
{ok,<<"{\n\"data3\":\"ColreUHAtuYoUOx1N4ZloouQt2o6ugnUT6eYtS10gu7niM8i0vEiNufpk1RlMQXaHXlIwQBDsMFDFUQcFeg2vW5eD259Xm\",\n"...>>}
15> DocBin = term_to_binary(couch_util:json_decode(Doc4Json)).
<<131,104,1,108,0,0,0,9,104,2,109,0,0,0,5,100,97,116,97,
  51,109,0,0,0,94,67,111,108,114,...>>
16> byte_size(DocBin).
5942
17> byte_size(element(2, snappy:compress(DocBin))).
2930
18>




4kb document template:

{
"data3":"ColreUHAtuYoUOx1N4ZloouQt2o6ugnUT6eYtS10gu7niM8i0vEiNufpk1RlMQXaHXlIwQBDsMFDFUQcFeg2vW5eD259Xm",
"data4":"zCxriJhL726WNNTdJJzurgSA8vKT6rHA0cFCb9koZcLUMXg4rmoXVPqIHWYaCV0ovl2t6xm7I1Hm36jXpLlXEb8fRfbwBeTW2V0OAsVqYH8eAT",
"data0":"9EVqHm5ARqcEB5jq2D14U2bCJPyBY0JWDr1Tjh8gTB0sWUNjqYiWDxFzlx6S",
"data7":"Bi1ujcgEvfADfBeyZudE7nwxc3Ik8qpYjsJIfKmwOMEbV2L3Bi0x2tcRpGuf4fiyvIbypDvJN1PPdQtfQW1Gv6zccXHwwZwKzUq6",
"data5":{
        "integers":[756509,116117,776378,275045,703447,50156,685803,147958,941747,905651,57367,530248,312888,740951,988947,450154],
        "float1":76.572,
        "float2":83.5299,
        "nested1": {
                   "integers":[756509,116117,776378,275045,703447,50156,685803,147958,941747,905651,57367,530248,312888,740951,988947,450154],
                   "floats":[43121609.5543,99454976.3019,32945584.756,18122905.9212,45893183.44,63052200.6225,69032152.6897,3748217.6946,75449850.474,37111527.415,84852536.859,32906366.487,27027600.417,63874310.5614,39440408.51,97176857.1716,97438252.1171,49728043.5056,40818570.245,41415831.8949,24796297.4251,2819085.3449,84263963.4848,74503228.6878,67925677.403,4758851.9417,75227407.9214,76946667.8403,72518275.9469,94167085.9588,75883067.8321,27389831.6101,57987075.5053,1298995.2674,14590614.6939,45292214.2242,3332166.364,53784167.729,25193846.1867,81456965.477,68532032.39,73820009.7952,57736110.5717,37304166.7363,20054244.864,29746392.7397,86467624.6,45192685.8793,44008816.5186,1861872.8736,14595859.467,87795257.6703,57768720.8303,18290154.3126,45893183.44,63052200.6225,69032152.6897,3748217.6946,75449850.474,37111527.415,84852536.859,32906366.487,27027600.417,63874310.5614,39440408.51,97176857.1716,97438252.1171,49728043.5056,40818570.245,41415831.8949,24796297.4251,2819085.3449,84263963.4848,74503228.6878,67925677.403,4758851.9417,75227407.9214,76946667.8403,72518275.9469,94167085.9588,75883067.8321,27389831.6101,57987075.5053,1298995.2674,80858801.2712,98262252.4656,51612877.944,33397812.7835,36089655.3049,50164685.8153,16852105.5192,61171929.752,86376339.7175,73009014.5521,7397302.331,34345128.9589,98343269.4418,95039116.9058,44833102.5752,51052997.8873,22719195.6783,64883244.8699]
        },
        "nested2": {
                   "integers":[756509,116117,776378,275045,703447,50156,685803,147958,941747,905651,57367,530248,312888,740951,988947,450154],
                   "float1":76.572,
                   "float2":83.5299
        }
},
"strings":["edx5XzRkPVeEW2MBQzQMcUSuMI4FntjhlJ9VGhQaBHKPEazAaT","2fQUbzRUax4A","jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9","8jKLmo3N2zYdKyTyfTczfr2x6bPaarorlnTNJ7r8lIkiZyBvrP","jbUeAVOdBSPzYmYhH0sabUHUH39O5e","I8yAQKZsyZhMfpzWjArQU9pQ6PfU6b14q2eWvQjtCUdgAUxFjg","97N8ZmGcxRZO4ZabzRRcY4KVHqxJwQ8qY","0DtY1aWXmUfJENt9rYW9","DtpBUEppPwMnWexi8eIIxlXRO3GUpPgeNFG9ONpWJYvk8xBkVj","YsX8V2xOrTw6LhNIMMhO4F4VXFyXUXFr66L3sTkLWgFA9NZuBV","fKYYthv8iFvaYoFoYZyB","zGuLsPXoJqMbO4PcePteZfDMYFXdWtvNF8WvaplXypsd6"],
"data1":"9EVqHm5ARqcEB5jq21v2g0jVcG9CXB0Abk7uAF4NHYyTzeF3TnHhpZBECD14U2bCJPyBY0JWDr1Tjh8gTB0sWUNjqYiWDxFzlx6S",
"integers":[756509,116117,776378,275045,703447,50156,685803,147958,941747,905651,57367,530248,312888,740951,988947,450154],
"more_nested":{
        "integers":[756509,116117,776378,275045,703447,50156,685803,147958,941747,905651,57367,530248,312888,740951,988947,450154],
        "float1":76.572,
        "float2":83.5299,
        "nested1": {
                   "integers":[756509,116117,776378,275045,703447,50156,685803,147958,941747,905651,57367,530248,312888,740951,988947,450154]
        },
        "nested2": {
                    "strings":["2fQUbzRUax4A","jURcBZ0vrJcmf2roZUMzZJQoTsKZDIdj7KhO7itskKvM80jBU9","8jKLmo3N2zYdKyTyfTczfr2x6bPaarorlnTNJ7r8lIkiZyBvrP","jbUeAVOdBSPzYmYhH0sabUHUH39O5e","I8yAQKZsyZhMfpzWjArQU9pQ6PfU6b14q2eWvQjtCUdgAUxFjg","97N8ZmGcxRZO4ZabzRRcY4KVHqxJwQ8qY","0DtY1aWXmUfJENt9rYW9","DtpBUEppPwMnWexi8eIIxlXRO3GUpPgeNFG9ONpWJYvk8xBkVj","YsX8V2xOrTw6LhNIMMhO4F4VXFyXUXFr66L3sTkLWgFA9NZuBV","fKYYthv8iFvaYoFoYZyB","zGuLsPXoJqMbO4PcePteZfDMYFXdWtvNF8WvaplXypsd6"],
                   "integers":[756509,116117,776378,57367,530248,312888,740951,988947,450154]
        }
}
}
Something went wrong with that request. Please try again.