Skip to content
Permalink
Browse files

zio_compress: use common sector size as threshold

Now default compression is lz4, which can stop
compression process by itself on incompressible data.
If there is additional size checks -
we will only make our compressratio worse.
So we can check only for common sector size.

Signed-off-by: George Melikov <mail@gmelikov.ru>
  • Loading branch information...
gmelikov committed Sep 10, 2019
1 parent 25f06d6 commit f45425130447e4ac5408d73428c4bc9a96fa6ba4
Showing with 9 additions and 7 deletions.
  1. +9 −7 module/zfs/zio_compress.c
@@ -22,13 +22,9 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/

/*
* Copyright (c) 2013, 2018 by Delphix. All rights reserved.
* Copyright (c) 2019 by George Melikov. All rights reserved.
*/

#include <sys/zfs_context.h>
@@ -43,6 +39,11 @@
*/
unsigned long zio_decompress_fail_fraction = 0;

/*
* Common disk sector size.
*/
short COMMON_SECTOR_SIZE = 4096;

/*
* Compression vectors.
*/
@@ -120,14 +121,15 @@ zio_compress_data(enum zio_compress c, abd_t *src, void *dst, size_t s_len)
if (c == ZIO_COMPRESS_EMPTY)
return (s_len);

/* Compress at least 12.5% */
d_len = s_len - (s_len >> 3);
/* Don't compress if it's less than common sector size */
d_len = MAX(0, s_len - COMMON_SECTOR_SIZE);

/* No compression algorithms can read from ABDs directly */
void *tmp = abd_borrow_buf_copy(src, s_len);
c_len = ci->ci_compress(tmp, dst, s_len, d_len, ci->ci_level);
abd_return_buf(src, tmp, s_len);

/* block with recordsize <= COMMON_SECTOR_SIZE will always be raw */
if (c_len > d_len)
return (s_len);

0 comments on commit f454251

Please sign in to comment.
You can’t perform that action at this time.