f2fs: compress: support compress level
Subsystems (2)
PATCH v6 1/1 f2fs: compress: support compress level
Expand 'compress_algorithm' mount option to accept parameter as format of <algorithm>:<level>, by this way, it gives a way to allow user to do more specified config on lz4 and zstd compression level, then f2fs compression can provide higher compress ratio.
In order to set compress level for lz4 algorithm, it needs to set CONFIG_LZ4HC_COMPRESS and CONFIG_F2FS_FS_LZ4HC config to enable lz4hc compress algorithm.
---
v6:
- fix warning reported by checkpatch.pl
Documentation/filesystems/f2fs.rst | 5 +++ fs/f2fs/Kconfig | 9 ++++ fs/f2fs/compress.c | 40 +++++++++++++++-- fs/f2fs/f2fs.h | 9 ++++ fs/f2fs/super.c | 72 +++++++++++++++++++++++++++++- include/linux/f2fs_fs.h | 3 ++ 6 files changed, 133 insertions(+), 5 deletions(-)
Documentation/filesystems/f2fs.rst +5 -0
@@ -249,6 +249,11 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "enabl This space is reclaimed once checkpoint=enable. compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo", "lz4", "zstd" and "lzo-rle" algorithm. +compress_algorithm=%s:%d Control compress algorithm and its compress level, now, only + "lz4" and "zstd" support compress level config. + algorithm level range + lz4 3 - 16 + zstd 1 - 22 compress_log_size=%u Support configuring compress cluster size, the size will be 4KB * (1 << %u), 16KB is minimum size, also it's default size.
fs/f2fs/Kconfig +9 -0
@@ -119,6 +119,15 @@ config F2FS_FS_LZ4 help Support LZ4 compress algorithm, if unsure, say Y. +config F2FS_FS_LZ4HC + bool "LZ4HC compression support" + depends on F2FS_FS_COMPRESSION + depends on F2FS_FS_LZ4 + select LZ4HC_COMPRESS + default y + help + Support LZ4HC compress algorithm, if unsure, say Y. + config F2FS_FS_ZSTD bool "ZSTD compression support" depends on F2FS_FS_COMPRESSION
fs/f2fs/compress.c +37 -3
@@ -254,8 +254,13 @@ static const struct f2fs_compress_ops f2fs_lzo_ops = {#ifdef CONFIG_F2FS_FS_LZ4 static int lz4_init_compress_ctx (struct compress_ctx *cc) { - cc->private =f2fs_kvmalloc (F2FS_I_SB (cc->inode), -LZ4_MEM_COMPRESS ,GFP_NOFS ); +unsigned int size; +unsigned char level =F2FS_I (cc->inode)->i_compress_flag >> +COMPRESS_LEVEL_OFFSET ; + + size = level ?LZ4HC_MEM_COMPRESS :LZ4_MEM_COMPRESS ; + + cc->private =f2fs_kvmalloc (F2FS_I_SB (cc->inode), size,GFP_NOFS );if (!cc->private)return -ENOMEM ;
@@ -274,10 +279,34 @@ static void lz4_destroy_compress_ctx(struct compress_ctx *cc) cc->private =NULL ; } +#ifdef CONFIG_F2FS_FS_LZ4HC +static int lz4hc_compress_pages (struct compress_ctx *cc) +{ +unsigned char level =F2FS_I (cc->inode)->i_compress_flag >> +COMPRESS_LEVEL_OFFSET ; +int len; + +if (level) + len =LZ4_compress_HC (cc->rbuf, cc->cbuf->cdata, cc->rlen, + cc->clen, level, cc->private); +else + len =LZ4_compress_default (cc->rbuf, cc->cbuf->cdata, cc->rlen, + cc->clen, cc->private); +if (!len) +return -EAGAIN ; + + cc->clen = len; +return 0 ; +} +#endif +static int lz4_compress_pages (struct compress_ctx *cc) {int len; +#ifdef CONFIG_F2FS_FS_LZ4HC +return lz4hc_compress_pages (cc); +#endif len =LZ4_compress_default (cc->rbuf, cc->cbuf->cdata, cc->rlen, cc->clen, cc->private);if (!len)
@@ -327,8 +356,13 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc)ZSTD_CStream *stream;void *workspace;unsigned int workspace_size; +unsigned char level =F2FS_I (cc->inode)->i_compress_flag >> +COMPRESS_LEVEL_OFFSET ; + +if (!level) + level =F2FS_ZSTD_DEFAULT_CLEVEL ; - params =ZSTD_getParams (F2FS_ZSTD_DEFAULT_CLEVEL , cc->rlen,0 ); + params =ZSTD_getParams (level, cc->rlen,0 ); workspace_size =ZSTD_CStreamWorkspaceBound (params.cParams); workspace = f2fs_kvmalloc(F2FS_I_SB(cc->inode),
fs/f2fs/f2fs.h +9 -0
@@ -147,6 +147,7 @@ struct f2fs_mount_info {/* For compression */ unsigned char compress_algorithm;/* algorithm type */ unsigned char compress_log_size;/* cluster log size */ +unsigned char compress_level;/* compress level */ bool compress_chksum;/* compressed data chksum */ unsigned char compress_ext_cnt;/* extension count */ int compress_mode;/* compression mode */
@@ -736,6 +737,7 @@ struct f2fs_inode_info {atomic_t i_compr_blocks;/* # of compressed blocks */ unsigned char i_compress_algorithm;/* algorithm type */ unsigned char i_log_cluster_size;/* log of cluster size */ +unsigned char i_compress_level;/* compress level (lz4hc,zstd) */ unsigned short i_compress_flag;/* compress flag */ unsigned int i_cluster_size;/* cluster size */ };
@@ -1308,6 +1310,8 @@ struct compress_data {#define F2FS_COMPRESSED_PAGE_MAGIC 0xF5F2C000 +#define COMPRESS_LEVEL_OFFSET 8 +/* compress context */ struct compress_ctx {struct inode *inode;/* inode the context belong to */
@@ -3959,6 +3963,11 @@ static inline void set_compress_context(struct inode *inode) 1 << COMPRESS_CHKSUM : 0;F2FS_I (inode)->i_cluster_size =1 <<F2FS_I (inode)->i_log_cluster_size; +if (F2FS_I (inode)->i_compress_algorithm ==COMPRESS_LZ4 && +F2FS_OPTION (sbi).compress_level) +F2FS_I (inode)->i_compress_flag |= +F2FS_OPTION (sbi).compress_level << +COMPRESS_LEVEL_OFFSET ;F2FS_I (inode)->i_flags |=F2FS_COMPR_FL ;set_inode_flag (inode,FI_COMPRESSED_FILE );stat_inc_compr_inode (inode);
fs/f2fs/super.c +70 -2
98 lines not on this page · raw message
include/linux/f2fs_fs.h +3 -0
@@ -275,6 +275,9 @@ struct f2fs_inode {__u8 i_compress_algorithm;/* compress algorithm */ __u8 i_log_cluster_size;/* log of cluster size */ __le16 i_compress_flag;/* compress flag */ +/* 0 bit: chksum flag +* [10,15] bits: compress level +*/ __le32 i_extra_end[0 ];/* for attribute size calculation */ } __packed;__le32 i_addr[DEF_ADDRS_PER_INODE ];/* Pointers to data blocks */
Signature · 8 lines
2.26.2 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
fs/f2fs/Kconfig config F2FS_FS_LZ4 · line 130
Quoted 9 lines · Chao Yu
fs/f2fs/Kconfig +9
-0+config F2FS_FS_LZ4HC + bool "LZ4HC compression support" + depends on F2FS_FS_COMPRESSION + depends on F2FS_FS_LZ4 + select LZ4HC_COMPRESS + default y + help + Support LZ4HC compress algorithm, if unsure, say Y. +
It would be helpful to mention that LZ4HC is on-disk compatible with LZ4.
fs/f2fs/compress.c static void lz4_destroy_compress_ctx(struct compress_ctx *cc) · line 309
Quoted 7 lines
static int
lz4_compress_pages(struct compress_ctx *cc){fs/f2fs/compress.c +3
-0int len; +#ifdef CONFIG_F2FS_FS_LZ4HC +return lz4hc_compress_pages (cc); +#endif
This looks wrong; it always calls lz4hc compression even for regular lz4.
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 942
Quoted 9 lines
static int
parse_options(struct super_block *sb, char *options, bool is_remount){fs/f2fs/super.c +1
-1struct f2fs_sb_info *sbi =F2FS_SB (sb);@@ -886,10 +939,22 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)if (!strcmp (name,"lzo" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; - }else if (!strcmp (name,"lz4" )) { + }else if (!strncmp (name,"lz4" ,3 )) {
strcmp() is fine, no need for strncmp().
fs/f2fs/super.c static inline void f2fs_show_compress_options(struct seq_file *seq, · line 1617
Quoted 7 lines
fs/f2fs/super.c +3
-0@@ -1547,6 +1612,9 @@ static inline void f2fs_show_compress_options(struct seq_file *seq, }seq_printf (seq,",compress_algorithm=%s" , algtype); +if (!F2FS_OPTION (sbi).compress_level) +seq_printf (seq,":%d" ,F2FS_OPTION (sbi).compress_level); +
This looks wrong; it only prints compress_level if it is 0.
include/linux/f2fs_fs.h struct f2fs_inode { · line 280
Quoted 11 lines
include/linux/f2fs_fs.h +3
-0@@ -275,6 +275,9 @@ struct f2fs_inode {__u8 i_compress_algorithm;/* compress algorithm */ __u8 i_log_cluster_size;/* log of cluster size */ __le16 i_compress_flag;/* compress flag */ +/* 0 bit: chksum flag +* [10,15] bits: compress level +*/
What is the use case for storing the compression level on-disk?
Keep in mind that compression levels are an implementation detail; the exact compressed data that is produced by a particular algorithm at a particular compression level is *not* a stable interface. It can change when the compressor is updated, as long as the output continues to be compatible with the decompressor.
So does compression level really belong in the on-disk format?
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Chao,
On Thu, Dec 03, 2020 at 11:32:34AM -0800, Eric Biggers wrote:
...
Quoted 11 lines
What is the use case for storing the compression level on-disk?
Keep in mind that compression levels are an implementation detail; the exact compressed data that is produced by a particular algorithm at a particular compression level is *not* a stable interface. It can change when the compressor is updated, as long as the output continues to be compatible with the decompressor.
So does compression level really belong in the on-disk format?
Curious about this, since f2fs compression uses 16k f2fs compress cluster by default (doesn't do sub-block compression by design as what btrfs did), so is there significant CR difference between lz4 and lz4hc on 16k configuration (I guess using zstd or lz4hc for 128k cluster like btrfs could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
As you may noticed, lz4hc is much slower than lz4, so if it's used online, it's a good way to keep all CPUs busy (under writeback) with unprivileged users. I'm not sure if it does matter. (Ok, it'll give users more options at least, yet I'm not sure end users are quite understand what these algorithms really mean, I guess it spends more CPU time but without much more storage saving by the default 16k configuration.)
from https://github.com/lz4/lz4 Core i7-9700K CPU @ 4.9GHz
Silesia Corpus
Compressor Ratio Compression Decompression memcpy 1.000 13700 MB/s 13700 MB/s Zstandard 1.4.0 -1 2.883 515 MB/s 1380 MB/s LZ4 HC -9 (v1.9.0) 2.721 41 MB/s 4900 MB/s
Also a minor thing is lzo-rle, initially it was only used for in-memory anonymous pages and it won't be kept on-disk so that's fine. I'm not sure if lzo original author want to support it or not. It'd be better to get some opinion before keeping it on-disk.
Thanks,
Gao Xiang
Quoted 7 lines
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Xiang,
Quoted 18 lines · Gao Xiang
Hi Chao,
On Thu, Dec 03, 2020 at 11:32:34AM -0800, Eric Biggers wrote:
...
Quoted 11 lines
What is the use case for storing the compression level on-disk?
Keep in mind that compression levels are an implementation detail; the exact compressed data that is produced by a particular algorithm at a particular compression level is *not* a stable interface. It can change when the compressor is updated, as long as the output continues to be compatible with the decompressor.
So does compression level really belong in the on-disk format?
Quoted 7 lines
Curious about this, since f2fs compression uses 16k f2fs compress cluster by default (doesn't do sub-block compression by design as what btrfs did), so is there significant CR difference between lz4 and lz4hc on 16k configuration (I guess using zstd or lz4hc for 128k cluster like btrfs could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
Yup, I can figure out some numbers later. :)
Quoted 8 lines
As you may noticed, lz4hc is much slower than lz4, so if it's used online, it's a good way to keep all CPUs busy (under writeback) with unprivileged users. I'm not sure if it does matter. (Ok, it'll give users more options at least, yet I'm not sure end users are quite understand what these algorithms really mean, I guess it spends more CPU time but without much more storage saving by the default 16k configuration.)
Quoted 7 lines
from https://github.com/lz4/lz4 Core i7-9700K CPU @ 4.9GHz
Silesia CorpusCompressor Ratio Compression Decompression memcpy 1.000 13700 MB/s 13700 MB/s Zstandard 1.4.0 -1 2.883 515 MB/s 1380 MB/s LZ4 HC -9 (v1.9.0) 2.721 41 MB/s 4900 MB/s
There is one solutions now, Daeho has submitted two patches:
f2fs: add compress_mode mount option
f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE
Which allows to specify all files in data partition be compressible, by default, all files are written as non-compressed one, at free time of system, we can use ioctl to reload and compress data for specific files.
Quoted 4 lines
Also a minor thing is lzo-rle, initially it was only used for in-memory anonymous pages and it won't be kept on-disk so that's fine. I'm not sure if lzo original author want to support it or not. It'd be better to get
Hmm.. that's a problem, as there may be existed potential users who are using lzo-rle, remove lzo-rle support will cause compatibility issue...
IMO, the condition "f2fs may has persisted lzo-rle compress format data already" may affect the decision of not supporting that algorithm from author.
Quoted 1 line
some opinion before keeping it on-disk.
Yes, I can try to ask... :)
Thanks,
Quoted 7 lines
Thanks,
Gao XiangQuoted 3 lines
- Eric
Quoted 7 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 47 lines · Chao Yu
Hi Xiang,
Quoted 18 lines · Gao Xiang
Hi Chao,
On Thu, Dec 03, 2020 at 11:32:34AM -0800, Eric Biggers wrote:
...
Quoted 11 lines
What is the use case for storing the compression level on-disk?
Keep in mind that compression levels are an implementation detail; the exact compressed data that is produced by a particular algorithm at a particular compression level is *not* a stable interface. It can change when the compressor is updated, as long as the output continues to be compatible with the decompressor.
So does compression level really belong in the on-disk format?
Quoted 7 lines
Curious about this, since f2fs compression uses 16k f2fs compress cluster by default (doesn't do sub-block compression by design as what btrfs did), so is there significant CR difference between lz4 and lz4hc on 16k configuration (I guess using zstd or lz4hc for 128k cluster like btrfs could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
Yup, I can figure out some numbers later. :)
Quoted 8 lines
As you may noticed, lz4hc is much slower than lz4, so if it's used online, it's a good way to keep all CPUs busy (under writeback) with unprivileged users. I'm not sure if it does matter. (Ok, it'll give users more options at least, yet I'm not sure end users are quite understand what these algorithms really mean, I guess it spends more CPU time but without much more storage saving by the default 16k configuration.)
Quoted 7 lines
from https://github.com/lz4/lz4 Core i7-9700K CPU @ 4.9GHz
Silesia CorpusCompressor Ratio Compression Decompression memcpy 1.000 13700 MB/s 13700 MB/s Zstandard 1.4.0 -1 2.883 515 MB/s 1380 MB/s LZ4 HC -9 (v1.9.0) 2.721 41 MB/s 4900 MB/s
Quoted 9 lines
There is one solutions now, Daeho has submitted two patches:
f2fs: add
compress_modemount option
f2fs: addF2FS_IOC_DECOMPRESS_FILEandF2FS_IOC_COMPRESS_FILEWhich allows to specify all files in data partition be compressible, by default, all files are written as non-compressed one, at free time of system, we can use ioctl to reload and compress data for specific files.
Yeah, my own premature suggestion is there are many compression options exist in f2fs compression, but end users are not compression experts. So it'd better to leave advantage options to users (or users might be confused or select wrong algorithm or make potential complaint...)
Keep lz4hc dirty data under writeback could block writeback, make kswapd busy, and direct memory reclaim path, I guess that's why rare online compression chooses it. My own premature suggestion is that it'd better to show the CR or performance benefits in advance, and prevent unprivileged users from using high-level lz4hc algorithm (to avoid potential system attack.) either from mount options or ioctl.
Quoted 9 lines
Quoted 4 lines
Also a minor thing is lzo-rle, initially it was only used for in-memory anonymous pages and it won't be kept on-disk so that's fine. I'm not sure if lzo original author want to support it or not. It'd be better to get
Hmm.. that's a problem, as there may be existed potential users who are using lzo-rle, remove lzo-rle support will cause compatibility issue...
Quoted 6 lines
IMO, the condition "f2fs may has persisted lzo-rle compress format data already" may affect the decision of not supporting that algorithm from author.
Quoted 1 line
some opinion before keeping it on-disk.
Yes, I can try to ask... :)
Yeah, it'd be better to ask the author first, or it may have to maintain a private lz4-rle folk...
Thanks,
Gao Xiang
Quoted 18 lines
Thanks,
Quoted 14 lines
Thanks,
Gao XiangQuoted 7 lines
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 58 lines · Gao Xiang
Quoted 47 lines · Chao Yu
Hi Xiang,
Quoted 18 lines · Gao Xiang
Hi Chao,
On Thu, Dec 03, 2020 at 11:32:34AM -0800, Eric Biggers wrote:
...
Quoted 11 lines
What is the use case for storing the compression level on-disk?
Keep in mind that compression levels are an implementation detail; the exact compressed data that is produced by a particular algorithm at a particular compression level is *not* a stable interface. It can change when the compressor is updated, as long as the output continues to be compatible with the decompressor.
So does compression level really belong in the on-disk format?
Quoted 7 lines
Curious about this, since f2fs compression uses 16k f2fs compress cluster by default (doesn't do sub-block compression by design as what btrfs did), so is there significant CR difference between lz4 and lz4hc on 16k configuration (I guess using zstd or lz4hc for 128k cluster like btrfs could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
Yup, I can figure out some numbers later. :)
Quoted 8 lines
As you may noticed, lz4hc is much slower than lz4, so if it's used online, it's a good way to keep all CPUs busy (under writeback) with unprivileged users. I'm not sure if it does matter. (Ok, it'll give users more options at least, yet I'm not sure end users are quite understand what these algorithms really mean, I guess it spends more CPU time but without much more storage saving by the default 16k configuration.)
Quoted 7 lines
from https://github.com/lz4/lz4 Core i7-9700K CPU @ 4.9GHz
Silesia CorpusCompressor Ratio Compression Decompression memcpy 1.000 13700 MB/s 13700 MB/s Zstandard 1.4.0 -1 2.883 515 MB/s 1380 MB/s LZ4 HC -9 (v1.9.0) 2.721 41 MB/s 4900 MB/sQuoted 9 lines
There is one solutions now, Daeho has submitted two patches:
f2fs: add
compress_modemount option
f2fs: addF2FS_IOC_DECOMPRESS_FILEandF2FS_IOC_COMPRESS_FILEWhich allows to specify all files in data partition be compressible, by default, all files are written as non-compressed one, at free time of system, we can use ioctl to reload and compress data for specific files.
Quoted 4 lines
Yeah, my own premature suggestion is there are many compression options exist in f2fs compression, but end users are not compression experts. So it'd better to leave advantage options to users (or users might be confused or select wrong algorithm or make potential complaint...)
Yes, I agree.
Quoted 7 lines
Keep lz4hc dirty data under writeback could block writeback, make kswapd busy, and direct memory reclaim path, I guess that's why rare online compression chooses it. My own premature suggestion is that it'd better to show the CR or performance benefits in advance, and prevent unprivileged users from using high-level lz4hc algorithm (to avoid potential system attack.) either from mount options or ioctl.
Yes, I guess you are worry about destop/server scenario, as for android scenario, all compression related flow can be customized, and I don't think we will use online lz4hc compress; for other scenario, except the numbers, I need to add the risk of using lz4hc algorithm in document.
Thanks,
Quoted 38 lines
Quoted 10 lines
Quoted 5 lines
Also a minor thing is lzo-rle, initially it was only used for in-memory anonymous pages and it won't be kept on-disk so that's fine. I'm not sure if lzo original author want to support it or not. It'd be better to get
Hmm.. that's a problem, as there may be existed potential users who are using lzo-rle, remove lzo-rle support will cause compatibility issue...
Quoted 6 lines
IMO, the condition "f2fs may has persisted lzo-rle compress format data already" may affect the decision of not supporting that algorithm from author.
Quoted 1 line
some opinion before keeping it on-disk.
Yes, I can try to ask... :)
Yeah, it'd be better to ask the author first, or it may have to maintain a private lz4-rle folk...
Thanks,
Gao XiangQuoted 15 lines
Thanks,
Quoted 12 lines
Thanks,
Gao XiangQuoted 7 lines
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
.
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 2 lines · Chao Yu
Quoted 1 line · Gao Xiang
On Fri, Dec 04, 2020 at 09:56:27AM +0800, Chao Yu wrote:
...
Quoted 9 lines
Quoted 8 lines
Keep lz4hc dirty data under writeback could block writeback, make kswapd busy, and direct memory reclaim path, I guess that's why rare online compression chooses it. My own premature suggestion is that it'd better to show the CR or performance benefits in advance, and prevent unprivileged users from using high-level lz4hc algorithm (to avoid potential system attack.) either from mount options or ioctl.
Quoted 4 lines
Yes, I guess you are worry about destop/server scenario, as for android scenario, all compression related flow can be customized, and I don't think we will use online lz4hc compress; for other scenario, except the numbers, I need to add the risk of using lz4hc algorithm in document.
Yes, I was saying the general scenario. My overall premature thought is that before releasing some brand new algorithm, it may be better to evaluate first it'd benefit to some scenarios first (either on CR or performance side, or why adding this?), or it would might cause lzo-rle likewise situation in the future (and add more dependency to algorithms, you might see BWT-based bzip2 removal patch
https://lore.kernel.org/r/[email protected]
(since I personally don't think BWT is a good algorithm as well)... Just FYI ... If i'm wrong, kindly ignore me :)
Thanks,
Gao Xiang
Quoted 2 lines
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 20 lines · Gao Xiang
Quoted 2 lines · Chao Yu
Quoted 1 line · Gao Xiang
On Fri, Dec 04, 2020 at 09:56:27AM +0800, Chao Yu wrote:
...
Quoted 9 lines
Quoted 8 lines
Keep lz4hc dirty data under writeback could block writeback, make kswapd busy, and direct memory reclaim path, I guess that's why rare online compression chooses it. My own premature suggestion is that it'd better to show the CR or performance benefits in advance, and prevent unprivileged users from using high-level lz4hc algorithm (to avoid potential system attack.) either from mount options or ioctl.
Quoted 4 lines
Yes, I guess you are worry about destop/server scenario, as for android scenario, all compression related flow can be customized, and I don't think we will use online lz4hc compress; for other scenario, except the numbers, I need to add the risk of using lz4hc algorithm in document.
Quoted 4 lines
Yes, I was saying the general scenario. My overall premature thought is that before releasing some brand new algorithm, it may be better to evaluate first it'd benefit to some scenarios first (either on CR or performance side, or why adding this?), or it would might cause lzo-rle likewise situation in the
Yeah, got your point.
Quoted 2 lines
future (and add more dependency to algorithms, you might see BWT-based bzip2 removal patch
Oops, is that really allowed? I don't this is a good idea...and I don't see there are deletions from fs/ due to similar reason...
Thanks,
Quoted 4 lines
https://lore.kernel.org/r/[email protected]
(since I personally don't think BWT is a good algorithm as well)... Just FYI ... If i'm wrong, kindly ignore me :)
Quoted 8 lines
Thanks,
Gao XiangQuoted 2 lines
Thanks,
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 1 line · Chao Yu
On 2020/12/4 10:47, Gao Xiang wrote:
...
Quoted 6 lines
Quoted 3 lines
future (and add more dependency to algorithms, you might see BWT-based bzip2 removal patch
Oops, is that really allowed? I don't this is a good idea...and I don't see there are deletions from
fs/due to similar reason...
Fortunately, bzip is quite slow algorithm, so not affective at all.
My personal opinion based on compress algorithm principle (just for reference as well...)
- zlib should be better replaced with libdeflate if possible, the main point is that many hardware accelerator for deflate (LZ77 + huffman) are available;
- lzo is not attractive from its format complexity and its CR/performance
goal so lz4 is generally better due to its format design;
- lzo-rle, oops, just introduced for zram I think, not sure quite helpful for file data (since anonymous pages are generally RLE-effective due to many repeative data.) But it'd be good if lzo author accepts it.
Thanks,
Gao Xiang
Quoted 4 lines
Thanks,
Quoted 1 line
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 3 lines · Gao Xiang
could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
Just from a quick test with enwik9 on vm:
Original blocks: 244382
lz4 lz4hc-9
compressed blocks 170647 163270
compress ratio 69.8% 66.8%
speed 16.4207 s, 60.9 MB/s 26.7299 s, 37.4 MB/s
compress ratio = after / before
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Chao,
Quoted 7 lines · Chao Yu
Quoted 3 lines · Gao Xiang
could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
Just from a quick test with enwik9 on vm:
Quoted 8 lines
Original blocks: 244382
lz4 lz4hc-9compressed blocks 170647 163270
compress ratio 69.8% 66.8%
speed 16.4207 s, 60.9 MB/s 26.7299 s, 37.4 MB/scompress ratio = after / before
Thanks for the confirmation. it'd be better to add this to commit message if needed when adding a new algorithm to show the benefits.
About the speed, I think which is also limited to storage device and other conditions (I mean the CPU loading during the writeback might be different between lz4 and lz4hc-9 due to many other bounds, e.g. UFS 3.0 seq write is somewhat higher vs VM. lz4 may have higher bandwidth on high level devices since it seems some IO bound here... I guess but not sure, since pure in-memory lz4 is fast according to lzbench / lz4 homepage.)
Anyway, it's up to f2fs folks if it's useful :) (the CR number is what I expect though... I'm a bit of afraid the CPU runtime loading.) Thanks for your time!
Thanks,
Gao Xiang
Quoted 3 lines
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Xiang,
Quoted 17 lines · Gao Xiang
Hi Chao,
Quoted 14 lines · Chao Yu
Quoted 3 lines · Gao Xiang
could make more sense), could you leave some CR numbers about these algorithms on typical datasets (enwik9, silisia.tar or else.) with 16k cluster size?
Just from a quick test with enwik9 on vm:
Original blocks: 244382
lz4 lz4hc-9compressed blocks 170647 163270
compress ratio 69.8% 66.8%
speed 16.4207 s, 60.9 MB/s 26.7299 s, 37.4 MB/s
Quoted 4 lines
Quoted 1 line
compress ratio = after / before
Thanks for the confirmation. it'd be better to add this to commit message if needed when adding a new algorithm to show the benefits.
Sure, will add this.
Quoted 5 lines
About the speed, I think which is also limited to storage device and other conditions (I mean the CPU loading during the writeback might be different between lz4 and lz4hc-9 due to many other bounds, e.g. UFS 3.0 seq write is somewhat higher vs VM. lz4 may have higher bandwidth on high
Yeah, I guess my VM have been limited on its storage bandwidth, and its back-end could be low-end rotating disk...
Quoted 5 lines
level devices since it seems some IO bound here... I guess but not sure, since pure in-memory lz4 is fast according to lzbench / lz4 homepage.)
Anyway, it's up to f2fs folks if it's useful :) (the CR number is what I expect though... I'm a bit of afraid the CPU runtime loading.)
I just have a glance at CPU usage numbers (my VM has 16 cores):
lz4hc takes 11% in first half and downgrade to 6% at second half. lz4 takes 6% in whole process.
But that's not accruate...
Thanks,
Quoted 11 lines
Thanks for your time!
Thanks,
Gao XiangQuoted 3 lines
Thanks,
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On Fri, Dec 04, 2020 at 04:50:14PM +0800, Chao Yu wrote:
...
Quoted 9 lines
Quoted 6 lines
About the speed, I think which is also limited to storage device and other conditions (I mean the CPU loading during the writeback might be different between lz4 and lz4hc-9 due to many other bounds, e.g. UFS 3.0 seq write is somewhat higher vs VM. lz4 may have higher bandwidth on high
Yeah, I guess my VM have been limited on its storage bandwidth, and its back-end could be low-end rotating disk...
Yeah, anyway that's in IO writeback path (no matter the time was working on IO or CPU calcualation...)
Quoted 4 lines
Quoted 4 lines
level devices since it seems some IO bound here... I guess but not sure, since pure in-memory lz4 is fast according to lzbench / lz4 homepage.)
Quoted 8 lines
Quoted 2 lines
Anyway, it's up to f2fs folks if it's useful :) (the CR number is what I expect though... I'm a bit of afraid the CPU runtime loading.)
I just have a glance at CPU usage numbers (my VM has 16 cores):
lz4hc takes 11% in first half and downgrade to 6% at second half. lz4 takes 6% in whole process.But that's not accruate...
There is some userspace lzbench [1] to benchmark lz4/lz4hc completely in memory. So it's expected that lz4bench will consume all 100% CPU with maximum bandwidth (but in-kernel lz4 version is lower though):
Intel Core i7-8700K
Compression Decompression C/R memcpy 10362 MB/s 10790 MB/s 100.00 lz4 1.9.2 737 MB/s 4448 MB/s 47.60 lz4hc 1.9.2 -9 33 MB/s 4378 MB/s 36.75
So adding more IO time (due to storage device difference) could make CPU loading lower (also could make the whole process IO bound) but the overall write bandwidth will be lower as well.
[1] https://github.com/inikep/lzbench
Thanks,
Gao Xiang
Quoted 2 lines
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 12 lines · Eric Biggers
fs/f2fs/Kconfig config F2FS_FS_LZ4 · line 130
Quoted 9 lines · Chao Yu
fs/f2fs/Kconfig +9
-0+config F2FS_FS_LZ4HC + bool "LZ4HC compression support" + depends on F2FS_FS_COMPRESSION + depends on F2FS_FS_LZ4 + select LZ4HC_COMPRESS + default y + help + Support LZ4HC compress algorithm, if unsure, say Y. +It would be helpful to mention that LZ4HC is on-disk compatible with LZ4.
Sure, let me update description.
Quoted 10 lines
fs/f2fs/compress.c static void lz4_destroy_compress_ctx(struct compress_ctx *cc) · line 309
Quoted 8 lines
static int lz4_compress_pages(struct compress_ctx *cc) { int len;fs/f2fs/compress.c +3
-0+#ifdef CONFIG_F2FS_FS_LZ4HC +return lz4hc_compress_pages (cc); +#endif This looks wrong; it always calls lz4hc compression even for regular lz4.
It's fine. lz4hc_compress_pages() will call LZ4_compress_HC() only when compress level is set.
Quoted 12 lines
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 942
Quoted 10 lines
static int parse_options(struct super_block *sb, char *options, bool is_remount) { struct f2fs_sb_info *sbi = F2FS_SB(sb);fs/f2fs/super.c +1
-1@@ -886,10 +939,22 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)if (!strcmp (name,"lzo" )) {F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; - }else if (!strcmp (name,"lz4" )) { + }else if (!strncmp (name,"lz4" ,3 )) {
strcmp()is fine, no need forstrncmp().
Actually, I reuse "lz4" mount option parameter, to enable lz4hc algorithm, user only need to specify compress level after "lz4" string, e.g. compress_algorithm=lz4, f2fs use lz4 algorithm compress_algorithm=lz4:xx, f2fs use lz4hc algorithm with compress level xx.
So, I use !strncmp(name, "lz4", 3) here.
Quoted 10 lines
fs/f2fs/super.c static inline void f2fs_show_compress_options(struct seq_file *seq, · line 1617
Quoted 8 lines
fs/f2fs/super.c +3
-0@@ -1547,6 +1612,9 @@ static inline void f2fs_show_compress_options(struct seq_file *seq, }seq_printf (seq,",compress_algorithm=%s" , algtype); +if (!F2FS_OPTION (sbi).compress_level) +seq_printf (seq,":%d" ,F2FS_OPTION (sbi).compress_level); +This looks wrong; it only prints
compress_levelif it is 0.
Yes, will fix.
Quoted 14 lines
include/linux/f2fs_fs.h struct f2fs_inode { · line 280
Quoted 12 lines
include/linux/f2fs_fs.h +3
-0@@ -275,6 +275,9 @@ struct f2fs_inode {__u8 i_compress_algorithm;/* compress algorithm */ __u8 i_log_cluster_size;/* log of cluster size */ __le16 i_compress_flag;/* compress flag */ +/* 0 bit: chksum flag +* [10,15] bits: compress level +*/ What is the use case for storing the compression level on-disk?
One case I can image is if user wants to specify different compress level for different algorithm in separated files.
e.g.
mount -o comrpess_algorithm=zstd:10 /dev/sdc /f2fs touch fileA;
write fileA;
mount -o remount,comrpess_algorithm=lz4:8 /f2fs write fileA;
touch fileB;
write fileB;
Thanks,
Quoted 7 lines
Keep in mind that compression levels are an implementation detail; the exact compressed data that is produced by a particular algorithm at a particular compression level is *not* a stable interface. It can change when the compressor is updated, as long as the output continues to be compatible with the decompressor.
Quoted 5 lines
So does compression level really belong in the on-disk format?
- Eric
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel