rust-lang / rust-lang/rust

File truncation is slow on Windows

Open
#127,606 24 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-filesystem C-optimization T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

hello, I found that the std::fs::write function is quite slow when writing to the same file, I was very surprised why this is so and then I used open options and found that if I put truncate true then that was the cause of the slowdown and then I created a function where I changed the length of the file only at the end after writing, but only if the new length of the data was smaller than the original file size, and therefore I want to ask if it is possible to apply something like this in the std::fs::write method?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the std::fs::write entry point and the OpenOptions behavior described in the issue, reproducing the truncation slowdown on Windows. Compare the current write-and-truncate behavior with the proposed delayed length change, then identify the relevant Rust tests or implementation locations. Done means the behavior is evaluated and any change preserves correct final file contents and length.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.