This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
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.
ch-image
does a lot of file copying. In particular, as of PR #1741, build cache large files that are stored OOB are copied instead of hard-linked.The Linux kernel has two fast paths for copying regular files:
Make a reflink copy, where the destination file gets a new inode but shares all the data extents of the source file in a copy-on-write manner. Some filesystems support this.
Copy data in-kernel without passing through user-space. All filesystems support this.
Python ≥3.8 introduces
os.copy_file_range()
that wraps the underlying system callcopy_file_range(2)
, which does #1 if possible and silently falls back to #2 if not.This PR implements a fast-path copy that calls
os.copy_file_range()
if available and the source and destination are on the same filesystem. This should mitigate the performance loss in #1741 to some degree.