erofs: support adjust lz4 history window size
authorHuang Jianan <huangjianan@oppo.com>
Mon, 29 Mar 2021 01:23:06 +0000 (09:23 +0800)
committerGao Xiang <hsiangkao@redhat.com>
Mon, 29 Mar 2021 02:24:58 +0000 (10:24 +0800)
commit5d50538fc567c6f3692dec1825fb38c5a0884d93
tree93389d04bec73677d08776d3306b8288949d192e
parentde06a6a375414be03ce5b1054f2d836591923a1d
erofs: support adjust lz4 history window size

lz4 uses LZ4_DISTANCE_MAX to record history preservation. When
using rolling decompression, a block with a higher compression
ratio will cause a larger memory allocation (up to 64k). It may
cause a large resource burden in extreme cases on devices with
small memory and a large number of concurrent IOs. So appropriately
reducing this value can improve performance.

Decreasing this value will reduce the compression ratio (except
when input_size <LZ4_DISTANCE_MAX). But considering that erofs
currently only supports 4k output, reducing this value will not
significantly reduce the compression benefits.

The maximum value of LZ4_DISTANCE_MAX defined by lz4 is 64k, and
we can only reduce this value. For the old kernel, it just can't
reduce the memory allocation during rolling decompression without
affecting the decompression result.

Link: https://lore.kernel.org/r/20210329012308.28743-3-hsiangkao@aol.com
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Signed-off-by: Guo Weichao <guoweichao@oppo.com>
[ Gao Xiang: introduce struct erofs_sb_lz4_info for configurations. ]
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
fs/erofs/decompressor.c
fs/erofs/erofs_fs.h
fs/erofs/internal.h
fs/erofs/super.c