diff --git a/CHANGELOG.md b/CHANGELOG.md index ce9169820..4cfcb86eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/util/copy.ts b/src/util/copy.ts index ddb1842c5..e51f8ddc8 100644 --- a/src/util/copy.ts +++ b/src/util/copy.ts @@ -79,7 +79,15 @@ export const copyEntries = async ( */ const copyFileGracefully = async (src: string, dest: string): Promise => { 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') {