On 2024/3/15 09:10, Gao Xiang wrote:
From: Yifan Zhao <zhaoyi...@sjtu.edu.cn>

Currently, the creation of EROFS compressed image creation is
single-threaded, which suffers from performance issues. This patch
attempts to address it by compressing the large file in parallel.

Specifically, each input file larger than 16MB is splited into segments,
and each worker thread compresses a segment as if it were a separate
file. Finally, the main thread merges all the compressed segments.

Multi-threaded compression is not compatible with -Ededupe,
-E(all-)fragments and -Eztailpacking for now.

Signed-off-by: Yifan Zhao <zhaoyi...@sjtu.edu.cn>
Co-authored-by: Tong Xin <xin_t...@sjtu.edu.cn>
Signed-off-by: Gao Xiang <hsiang...@linux.alibaba.com>
---
v7:
  - support -Eztailpacking;

Apply the following diff to fix this:

diff --git a/lib/compress.c b/lib/compress.c
index 0d796c8..7ad48b0 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -509,10 +509,10 @@ static int __z_erofs_compress_one(struct 
z_erofs_compress_sctx *ctx,
        struct erofs_compress *const h = ctx->chandle;
        unsigned int len = ctx->tail - ctx->head;
        bool is_packed_inode = erofs_is_packed_inode(inode);
-       bool final = !ctx->remaining;
-       bool may_packing = (cfg.c_fragments && final && !is_packed_inode &&
-                           !z_erofs_mt_enabled);
-       bool may_inline = (cfg.c_ztailpacking && final && !may_packing);
+       bool tsg = (ctx->seg_idx + 1 >= ctx->seg_num), final = !ctx->remaining;
+       bool may_packing = (cfg.c_fragments && tsg && final &&
+                           !is_packed_inode && !z_erofs_mt_enabled);
+       bool may_inline = (cfg.c_ztailpacking && tsg && final && !may_packing);
        unsigned int compressedsize;
        int ret;

Thanks,
Gao Xiang

Reply via email to