diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-10-26 16:58:25 +0200 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-12-03 13:13:50 +0200 |
commit | 062e4fee4400f283307cf8ac1b7931c939010229 (patch) | |
tree | cacea4a2f65688ad02fa572060155783c4f0377c /fs | |
parent | f6f7b52e2f6149d2ee365717afff315b05720162 (diff) |
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: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/compress.c | 6 | ||||
-rw-r--r-- | fs/ubifs/ubifs-media.h | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c index a0ada596b17..6414d50780e 100644 --- a/fs/ubifs/compress.c +++ b/fs/ubifs/compress.c @@ -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, - * rather than any defined minimum compression ratio or amount. + * If the data compressed only slightly, it is better to leave it + * 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; return; diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h index 0b378042a3a..b25fc36cf72 100644 --- a/fs/ubifs/ubifs-media.h +++ b/fs/ubifs/ubifs-media.h @@ -51,6 +51,13 @@ */ #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 */ #define UBIFS_ROOT_INO 1 |