local: preallocate files on Windows to reduce fragmentation #2469
Before this change on Windows, files copied locally could become heavily fragmented (300+ fragments for maybe 100 MB), no matter how much contiguous free space there was (even if it's over 1TiB). This can needlessly yet severely adversely affect performance on hard disks. This changes uses NtSetInformationFile to pre-allocate the space to avoid this. It does nothing on other OSes other than Windows.
This commit is contained in:
parent
e44fa5db8e
commit
f29c6049fc
3 changed files with 95 additions and 0 deletions
|
@ -817,6 +817,12 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
|
|||
return err
|
||||
}
|
||||
|
||||
// Pre-allocate the file for performance reasons
|
||||
err = preAllocate(src.Size(), out)
|
||||
if err != nil {
|
||||
fs.Debugf(o, "Failed to pre-allocate: %v", err)
|
||||
}
|
||||
|
||||
// Calculate the hash of the object we are reading as we go along
|
||||
hash, err := hash.NewMultiHasherTypes(hashes)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue