couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject couch commit: updated refs/heads/master to 3a26ea1
Date Wed, 15 Jul 2015 16:08:23 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master b76dcb27a -> 3a26ea1ba


Remove compression's optimization

When a file compression set to snappy, couch is doing an additional
optimization step by also compressing the term with deflate,
comparing the sizes of the result binary and choosing the smaller one.
This leads to a situation when for snappy compresed database the
'winning' deflate compressed term got decompressed and compressed
back into deflate on each document's write.

This patch removes this compression's optimization.
[Basic test](http://nbviewer.ipython.org/gist/eiri/79d91a797af9c6a6ff6d)
demonstrate that the gained with it disk space is not significant
enough to justify empty CPU cycles.

This closes COUCHDB-2726


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

Branch: refs/heads/master
Commit: 3a26ea1ba09e50da3b97b64e6e1ebf75c9406202
Parents: b76dcb2
Author: Eric Avdey <eiri@eiri.ca>
Authored: Wed Jun 24 11:50:39 2015 -0300
Committer: Eric Avdey <eiri@eiri.ca>
Committed: Wed Jul 15 12:09:48 2015 -0300

----------------------------------------------------------------------
 src/couch_compress.erl | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/3a26ea1b/src/couch_compress.erl
----------------------------------------------------------------------
diff --git a/src/couch_compress.erl b/src/couch_compress.erl
index 6b47a7a..f9b5aa6 100644
--- a/src/couch_compress.erl
+++ b/src/couch_compress.erl
@@ -43,6 +43,8 @@ compress(<<?SNAPPY_PREFIX, _/binary>> = Bin, snappy) ->
     Bin;
 compress(<<?SNAPPY_PREFIX, _/binary>> = Bin, Method) ->
     compress(decompress(Bin), Method);
+compress(<<?COMPRESSED_TERM_PREFIX, _/binary>> = Bin, {deflate, _Level}) ->
+    Bin;
 compress(<<?TERM_PREFIX, _/binary>> = Bin, Method) ->
     compress(decompress(Bin), Method);
 compress(Term, none) ->
@@ -53,12 +55,7 @@ compress(Term, snappy) ->
     Bin = ?term_to_bin(Term),
     try
         {ok, CompressedBin} = snappy:compress(Bin),
-        case byte_size(CompressedBin) < byte_size(Bin) of
-        true ->
-            <<?SNAPPY_PREFIX, CompressedBin/binary>>;
-        false ->
-            Bin
-        end
+        <<?SNAPPY_PREFIX, CompressedBin/binary>>
     catch exit:snappy_nif_not_loaded ->
         Bin
     end.


Mime
View raw message