1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 17:57:59 +00:00

With --compression auto,C, only use C if lz4 achieves at least 3% compression

This commit is contained in:
Dan Christensen 2017-03-25 19:44:19 -04:00
parent 83de89d186
commit 48652a65a6

View file

@ -2162,13 +2162,13 @@ def heuristic_lz4(self, compr_args, chunk):
cdata = lz4.compress(data)
data_len = len(data)
cdata_len = len(cdata)
if cdata_len < data_len:
if cdata_len < 0.97 * data_len:
compr_spec = compr_args.spec
else:
# uncompressible - we could have a special "uncompressible compressor"
# that marks such data as uncompressible via compression-type metadata.
compr_spec = CompressionSpec('none')
self.logger.debug("len(data) == %d, len(lz4(data)) == %d, choosing %s", data_len, cdata_len, compr_spec)
self.logger.debug("len(data) == %d, len(lz4(data)) == %d, ratio == %.3f, choosing %s", data_len, cdata_len, cdata_len/data_len, compr_spec)
meta['compress'] = compr_spec
return compr_spec, Chunk(data, **meta)