Bug 195552 - kget should pre-allocate the file for the size of the file
Summary: kget should pre-allocate the file for the size of the file
Status: REPORTED
Alias: None
Product: kget
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: KGet authors
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-07 13:22 UTC by Amit Shah
Modified: 2011-02-05 02:49 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Amit Shah 2009-06-07 13:22:27 UTC
Version:           2.2.3 (using 4.2.3 (KDE 4.2.3), 4.2.3-2.fc10 Fedora)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.27.24-170.2.68.fc10.x86_64

kget, like ktorrent, should pre-allocate a file using the posix_fallocate() call so that the fragmentation of a file is kept to a minimum. Newer file systems like ext4, btrfs, xfs, etc., support the fallocate() syscall and hence this is extremely fast.

Some older file systems aren't too slow for preallocation as well:

http://www.amitshah.net/2009/04/re-comparing-file-systems.html

Two ways of doing this:
1. More user-friendly: detect if fallocate() support is available and use it
2. Offer the user an option to preallocate the file so that the file isn't fragmented.
Comment 1 Matthias Fuchs 2011-02-05 02:37:49 UTC
KGet uses QFile::resize for that, so the fragmentation should not be that large.
Comment 2 Matthias Fuchs 2011-02-05 02:49:07 UTC
Ah I see. QFile::resize does not appear to preallocate space. I'll look into it.