Repository navigation
utils: copy data ranges in 1 MiB blocks and leave zero blocks as holes - #542
Merged
Merged
Conversation
A FUSE checkpoint_dir such as JuiceFS has no SEEK_DATA, so every byte is data and a reader of an archived claim wrote its whole 10 GiB cow: 13.6 s against 0.58 s from ext4. Skipping all-zero blocks keeps the holes on any source, and the 1 MiB block cuts the 32 KiB io.Copy's syscalls 32-fold on the no-reflink path. IsZero moves to utils so store and utils share it.
Contributor
Author
Hardware verification: passSetup. Testbed host, kernel 6.12, an otherwise idle NUMA node.
ext4 without reflink (loop ext4). n=6 per arm, F1 run ABCCBA ×3 and F2 in the swapped order. Medians in ms, Mann-Whitney p in parentheses:
JuiceFS dir store, first read of an archived claim. Run order A C C A A C, one fresh sandboxd per run.
Tests on the Linux host.
|
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.
CloneFile's no-reflink fallback (copyData) is the dir checkpoint store's only copy path, and an archived-claim reader uses it.Problems
SEEK_DATA/SEEK_HOLE, so the kernel reports the whole file as data.copyDatathen writes every zero byte. On hardware, a reader of an archived claim wrote its full 10 GiBcow.rawand was ready in 13.6 s, against 0.58 s and 522 MiB from ext4.docs/deploy.mdrecommends exactly this setup forcheckpoint_dir.io.Copythrough anOffsetWritermoves 32 KiB per syscall, about 32k reads and 32k writes per GiB.Change
ReadAt/WriteAt.IsZeromoves fromstore/sparse.gotoutils, andstore.ScanFileuses the shared helper.docs/deploy.md: the reader section says the dir backend keeps zero blocks as holes even from a mount that reports none.TestCopyDataKeepsHolescovers two sources: a sparse file, and a file with 8 MiB of zeros written as data. The second case fails against the oldcopyData: it allocates 8392704 of 8388612 bytes.Hardware
Pending. I'll run an A/B on ext4, with three arms: the old code,
copy_file_range, and this change. On JuiceFS I'll compare the old code with this change. Both runs measure copy time and the destination's allocated bytes, and the results will be posted here.Gates
make go-lint: 10×0 issues.asl -forwarder=false ./...: clean on both GOOS.go test -race ./utils/ ./store/... ./pool/: ok.go test ./utils/ ./store/...ok.