File truncation is slow on Windows
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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