From 7b88c059a2ccdbd477adf2184d3d83f4d970c8b0 Mon Sep 17 00:00:00 2001 From: Peng Zhang Date: Mon, 20 Jul 2026 18:16:58 +0000 Subject: [PATCH] fs: remove per-file fsync from sparse-aware copyFile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The per-file tgt.Sync() added in a424ba1 causes a 17x performance regression when copying directories with many files. For 50K files of 10KiB each, per-file fsync takes over 1 minute vs 4.4 seconds without it. This severely impacts container start latency for images using the VOLUME directive, where volumeCopyUp calls fs.CopyDir to populate the mount point. The previous implementation (io.Copy) never called fsync, and the callers of CopyDir do not require per-file durability — the source data is always available for replay from immutable image layers. Fixes: https://github.com/containerd/continuity/issues/303 Signed-off-by: Peng Zhang --- fs/copy_linux.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/copy_linux.go b/fs/copy_linux.go index 8806505..65ef6d7 100644 --- a/fs/copy_linux.go +++ b/fs/copy_linux.go @@ -135,10 +135,6 @@ func copyFile(target, source string) error { offset = holeStart } - if err := tgt.Sync(); err != nil { - return fmt.Errorf("failed to sync target %s: %w", target, err) - } - return nil }