Skip to content

perf: use COPYFILE_FICLONE mode when copying files#6461

Merged
chenjiahan merged 1 commit intomainfrom
copy_perf_1029
Oct 29, 2025
Merged

perf: use COPYFILE_FICLONE mode when copying files#6461
chenjiahan merged 1 commit intomainfrom
copy_perf_1029

Conversation

@chenjiahan
Copy link
Member

Summary

Leverage fs.constants.COPYFILE_FICLONE in fs.cp to take advantage of copy-on-write optimizations

This allows faster file copying when supported by the underlying file system, while gracefully falling back to normal copying on unsupported platforms.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings October 29, 2025 14:29
@netlify
Copy link

netlify bot commented Oct 29, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 02ea2e8
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/690224e076880b00087a3d86
😎 Deploy Preview https://deploy-preview-6461--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 59 (no change from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the COPYFILE_FICLONE mode flag to file copy operations and ensures the fs.promises.cp call is properly awaited in the server plugin. The change aims to optimize file copying by attempting copy-on-write operations when supported by the filesystem.

  • Added await keyword to fs.promises.cp call in server plugin
  • Added mode: fs.constants.COPYFILE_FICLONE option to copy operations in both production and test code

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/plugins/server.ts Added await to fs.promises.cp and COPYFILE_FICLONE mode for publicDir copying
e2e/helper/fixture.ts Added COPYFILE_FICLONE mode flag to test fixture copy operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

recursive: true,
// dereference symlinks
dereference: true,
mode: fs.constants.COPYFILE_FICLONE,
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mode parameter with COPYFILE_FICLONE is intended for fs.copyFile(), not fs.promises.cp(). When using fs.promises.cp() with recursive: true for directory copying, the mode parameter controls file permissions, not copy behavior flags. Using COPYFILE_FICLONE here may cause the copy operation to fail on filesystems that don't support copy-on-write, or may not have the intended effect. Consider removing this option or handling filesystem compatibility errors explicitly in the catch block.

Suggested change
mode: fs.constants.COPYFILE_FICLONE,

Copilot uses AI. Check for mistakes.
await fse.remove(targetDir);
await promises.cp(path.join(cwd, 'src'), targetDir, {
recursive: true,
mode: fsConstants.COPYFILE_FICLONE,
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mode parameter with COPYFILE_FICLONE is intended for fs.copyFile(), not fs.promises.cp(). When using fs.promises.cp() with recursive: true for directory copying, the mode parameter controls file permissions, not copy behavior flags. This could cause test failures on filesystems that don't support copy-on-write. Consider removing this option to ensure test stability across different environments.

Suggested change
mode: fsConstants.COPYFILE_FICLONE,

Copilot uses AI. Check for mistakes.
@chenjiahan chenjiahan merged commit ed3115e into main Oct 29, 2025
18 checks passed
@chenjiahan chenjiahan deleted the copy_perf_1029 branch October 29, 2025 14:40
@chenjiahan chenjiahan mentioned this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant