mount/manager: set sparse file attribute on Windows before mkfs#12938
Draft
djs55 wants to merge 1 commit intocontainerd:mainfrom
Draft
mount/manager: set sparse file attribute on Windows before mkfs#12938djs55 wants to merge 1 commit intocontainerd:mainfrom
djs55 wants to merge 1 commit intocontainerd:mainfrom
Conversation
On Windows (NTFS/ReFS), extending a file with Truncate does not create
a sparse file by default. When mkfs.ext4 subsequently writes metadata
at scattered offsets across the file, NTFS must zero-fill all
intervening blocks up to the valid data length before each write. For
large filesystem images this is extremely slow.
Fix this by marking the file as sparse via FSCTL_SET_SPARSE before
calling Truncate. This allows NTFS to leave unwritten regions
unallocated, matching the behavior of macOS/Linux where Truncate
already produces sparse files.
Benchmark results (8 GB file, Windows 11, NTFS):
Without FSCTL_SET_SPARSE (before):
Create + Truncate: 535µs (on-disk: 8192 MB)
Scattered writes: 4.74s (on-disk: 8192 MB)
Total: 4.74s
With FSCTL_SET_SPARSE (after):
Create + Truncate: 526µs (on-disk: 0 MB)
Scattered writes: 15.6ms (on-disk: 1 MB)
Total: 16.1ms
~300x speedup for the file creation + write pattern, and on-disk usage
drops from 8 GB to only the blocks actually written by mkfs.
Signed-off-by: David Scott <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
djs55
added a commit
to djs55/containerd
that referenced
this pull request
Feb 25, 2026
Signed-off-by: David Scott <[email protected]> Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
dmcgowan
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 6, 2026
Signed-off-by: Derek McGowan <[email protected]>
dmcgowan
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 7, 2026
Signed-off-by: Derek McGowan <[email protected]>
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 7, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 7, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 7, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 7, 2026
github-actions Bot
added a commit
to akerouanton/containerd
that referenced
this pull request
Mar 8, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 9, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 10, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 10, 2026
Member
|
@djs55 is this good to go now? Seems the testing of it has been successful |
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 19, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 19, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Mar 19, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Apr 1, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Apr 4, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Apr 10, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Apr 11, 2026
github-actions Bot
added a commit
to dmcgowan/containerd
that referenced
this pull request
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(slightly experimental, still being tested)
On Windows (NTFS/ReFS), extending a file with Truncate does not create a sparse file by default. When mkfs.ext4 subsequently writes metadata at scattered offsets across the file, NTFS must zero-fill all intervening blocks up to the valid data length before each write. For large filesystem images this is extremely slow.
Fix this by marking the file as sparse via FSCTL_SET_SPARSE before calling Truncate. This allows NTFS to leave unwritten regions unallocated, matching the behavior of macOS/Linux where Truncate already produces sparse files.
Benchmark results (8 GB file, Windows 11, NTFS):
~300x speedup for the file creation + write pattern, and on-disk usage drops from 8 GB to only the blocks actually written by mkfs.