Commit 062e4fee authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBIFS: slight compression optimization

If data does not compress, it is better to leave it uncompressed
because we'll read it faster then. So do not compress data if we
save less than 64 bytes.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent f6f7b52e
...@@ -119,10 +119,10 @@ void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, ...@@ -119,10 +119,10 @@ void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len,
} }
/* /*
* Presently, we just require that compression results in less data, * If the data compressed only slightly, it is better to leave it
* rather than any defined minimum compression ratio or amount. * uncompressed to improve read speed.
*/ */
if (ALIGN(*out_len, 8) >= ALIGN(in_len, 8)) if (in_len - *out_len < UBIFS_MIN_COMPRESS_DIFF)
goto no_compr; goto no_compr;
return; return;
......
...@@ -51,6 +51,13 @@ ...@@ -51,6 +51,13 @@
*/ */
#define UBIFS_MIN_COMPR_LEN 128 #define UBIFS_MIN_COMPR_LEN 128
/*
* If compressed data length is less than %UBIFS_MIN_COMPRESS_DIFF bytes
* shorter than uncompressed data length, UBIFS preferes to leave this data
* node uncompress, because it'll be read faster.
*/
#define UBIFS_MIN_COMPRESS_DIFF 64
/* Root inode number */ /* Root inode number */
#define UBIFS_ROOT_INO 1 #define UBIFS_ROOT_INO 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment