You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/02/11 21:33:26 UTC
[1/2] couch commit: updated
refs/heads/COUCHDB-3298-improve-couch-btree-chunkify to ff9fb71
Repository: couchdb-couch
Updated Branches:
refs/heads/COUCHDB-3298-improve-couch-btree-chunkify [created] ff9fb7112
Make couch_btree:chunkify/1 prefer fewer chunks
This changes couch_btree:chunkify/1 to produce fewer larger chunks
rather than creating chunks of even-ish size.
COUCHDB-3298
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/8556adbb
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/8556adbb
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/8556adbb
Branch: refs/heads/COUCHDB-3298-improve-couch-btree-chunkify
Commit: 8556adbb98e79a09ec254967ee6acf3bef8d1fb6
Parents: bbbd532
Author: Paul J. Davis <pa...@gmail.com>
Authored: Sat Feb 11 15:26:26 2017 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Sat Feb 11 15:26:26 2017 -0600
----------------------------------------------------------------------
src/couch_btree.erl | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8556adbb/src/couch_btree.erl
----------------------------------------------------------------------
diff --git a/src/couch_btree.erl b/src/couch_btree.erl
index e9ff7f5..8f2395c 100644
--- a/src/couch_btree.erl
+++ b/src/couch_btree.erl
@@ -342,11 +342,9 @@ complete_root(Bt, KPs) ->
% it's probably really inefficient.
chunkify(InList) ->
- BaseChunkSize = get_chunk_size(),
+ ChunkThreshold = get_chunk_size(),
case ?term_size(InList) of
- Size when Size > BaseChunkSize ->
- NumberOfChunksLikely = ((Size div BaseChunkSize) + 1),
- ChunkThreshold = Size div NumberOfChunksLikely,
+ Size when Size > ChunkThreshold ->
chunkify(InList, ChunkThreshold, [], 0, []);
_Else ->
[InList]
[2/2] couch commit: updated
refs/heads/COUCHDB-3298-improve-couch-btree-chunkify to ff9fb71
Posted by da...@apache.org.
Ensure multi-item chunks in couch_btree:chunkify/1
If the last element of a chunk has a huge reduction it was possible to
return a btree node that had a single key. This prevents the edge case
by forcing it into the previous chunk. Without this we can end up with a
case where a path in the tree can extend for many levels with only a
single key in each node.
COUCHDB-3298
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/ff9fb711
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/ff9fb711
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/ff9fb711
Branch: refs/heads/COUCHDB-3298-improve-couch-btree-chunkify
Commit: ff9fb7112ee5250af01e1b38c8cfa9caed152ae7
Parents: 8556adb
Author: Paul J. Davis <pa...@gmail.com>
Authored: Sat Feb 11 15:29:14 2017 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Sat Feb 11 15:29:14 2017 -0600
----------------------------------------------------------------------
src/couch_btree.erl | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/ff9fb711/src/couch_btree.erl
----------------------------------------------------------------------
diff --git a/src/couch_btree.erl b/src/couch_btree.erl
index 8f2395c..adbc92b 100644
--- a/src/couch_btree.erl
+++ b/src/couch_btree.erl
@@ -352,6 +352,9 @@ chunkify(InList) ->
chunkify([], _ChunkThreshold, [], 0, OutputChunks) ->
lists:reverse(OutputChunks);
+chunkify([], _ChunkThreshold, [Item], _OutListSize, [PrevChunk | RestChunks]) ->
+ NewPrevChunk = PrevChunk ++ [Item],
+ lists:reverse(RestChunks, [NewPrevChunk]);
chunkify([], _ChunkThreshold, OutList, _OutListSize, OutputChunks) ->
lists:reverse([lists:reverse(OutList) | OutputChunks]);
chunkify([InElement | RestInList], ChunkThreshold, OutList, OutListSize, OutputChunks) ->