Repository navigation
RestoreSink: start writeback while restoring large files - #765
Open
czawistowski-nvidia wants to merge 1 commit into
Open
czawistowski-nvidia wants to merge 1 commit into
czawistowski-nvidia wants to merge 1 commit into
Conversation
With fsync-store-paths, RestoreSink started writeback of a regular file (sync_file_range(SYNC_FILE_RANGE_WRITE)) only when the file was closed, so the fsync before registering the path waited for the whole file to reach the disk. Start writeback of each 32 MiB as it is written instead, so the disk writes while the rest of the NAR is still being downloaded and unpacked. The fsync before registration is unchanged; sync_file_range is only a hint and its errors are still ignored.
|
Warning Review limit reached
This review includes 5 billable files and costs up to $1.25. Or wait 59 minutes for your next included review. View limit details
Tip 🎯 Customize your risk assessments
✅ Automatic approvals, with your rules
|
This branch has not been deployed
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.
Motivation
With
fsync-store-paths = true,RestoreSinkstarts writeback of a restored regular file only when the file is closed (AutoCloseFD::startFsync(), i.e.sync_file_range(fd, 0, 0, SYNC_FILE_RANGE_WRITE)). The fsync before registration then waits for the whole file to reach the disk, and every path that refers to it waits too. While a large file streams in from a substituter the disk sits idle, then has to write all of it at the end: for a 731 MiB file streamed at 230 MB/s the final fsync took 1.21 s, versus 0.01 s with writeback started as the file is written.Change
AutoCloseFD::startFsync()takes an optional byte range (default: the whole file, as before).fsync-store-pathsis on,RestoreRegularFilestarts writeback of each 32 MiB as it is written, and of the remaining tail at close.sync_file_range()stays Linux-only and advisory, and its errors are still ignored. Withfsync-store-paths = falsenothing changes.Testing
restore-large-file.sh: substitutes a 100 MiB file withfsync-store-paths = trueand checks its registration and contents. (That writeback now starts per chunk shows up understrace -e sync_file_rangeas ranged calls; there's no cheap way to assert that in a test.)restore-large-file,binary-cache,binary-cache-compression,nars,nar-access,substitute-with-invalid-ca,multiple-outputs-substitute-failure,nix-util-testsandnix-util-tests-without-new-syscallspass.fsync-store-paths = true, paired interleaved runs (n = 34 each): install time −14% ± 5.3% (95% CI) on a closure dominated by a few multi-hundred-MiB files, −6.9% on another. To reproduce without our closures: substitute any path containing a file of several hundred MiB and time the final fsync (strace -T -e fsync,sync_file_range).