Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use copy on write when available. #925

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
### Changed

- The default logger for non-interactive environments has been switched to the 'quiet-ci' logger.
- The local cache strategy will now create copy-on-write files when supported. This can improve performance when copying output files either into the cache or restoring from out of it, as the files' underlying data doesn't need to be copied, only filesystem metadata.

## [0.14.1] - 2023-10-20

Expand Down
10 changes: 9 additions & 1 deletion src/util/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ export const copyEntries = async (
*/
const copyFileGracefully = async (src: string, dest: string): Promise<void> => {
try {
await fs.copyFile(src, dest, fs.constants.COPYFILE_EXCL);
await fs.copyFile(
src,
dest,
// COPYFILE_FICLONE: Copy the file using copy-on-write semantics, so that
// the copy takes constant time and space. This is a noop currently
// on some platforms, but it's a nice optimization to have.
// See https://github.com/libuv/libuv/issues/2936 for macos support.
fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE,
);
} catch (error) {
const {code} = error as {code: string};
if (code === /* does not exist */ 'ENOENT') {
Expand Down