Bug 195552

Summary: kget should pre-allocate the file for the size of the file
Product: [Applications] kget Reporter: Amit Shah <amitshah>
Component: generalAssignee: KGet authors <kget>
Status: REPORTED ---    
Severity: wishlist CC: mat69
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

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.