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

perf: fs optimizations - part 1 #15873

Merged
merged 24 commits into from
Sep 22, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
match Rust std's behaviour
  • Loading branch information
littledivy committed Sep 16, 2022
commit 8f3bff3716fa2a500e886630a416936e897b1f61
6 changes: 3 additions & 3 deletions runtime/ops/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,11 @@ fn op_copy_file_sync(
}

if st.st_size > 128 * 1024 {
// Try unlink.
// Try unlink. If it fails, we are going to try clonefile() anyway.
let _ = unlink(to.as_ptr());
// Matches rust stdlib behavior for io::copy.
// https://github.com/rust-lang/rust/blob/3fdd578d72a24d4efc2fe2ad18eec3b6ba72271e/library/std/src/sys/unix/fs.rs#L1613-L1616
if clonefile(from.as_ptr(), to.as_ptr(), 0) == 0 {
// Preserve mode bits.
let _ = chmod(to.as_ptr(), st.st_mode);
return Ok(());
}
} else {
Expand Down