View Single Post
Old 2007-03-22, 08:41   Link #23
toru310
Senior Member
 
Join Date: Apr 2006
Location: Philippines
Quote:
Originally Posted by Jinto Lin View Post
Bittorrent always will use hard disk space (otherwise you'ld never be able to store files on your hdd).

Well I should explain some basic things.

What is preallocation and why does it help to keep the drive quite defragmented:

Preallocation of files means, that the files you want to download are written completely empty to disk (without any data, just so that the space is already taken, before any data actually was written to it). The operating system (e.g. Windows), tries to write such a 0-filled file as sequential as possible (since it is a continuous stream of data). When the space is not preallocated, the file grows bigger with each new data block coming in. There will be a) file internal fragmentation, because the data blocks usually arrive rather random when downloading torrents (means a data block, near the end of the file can be physically stored next to a data block near the beginning of the file... when you want to read such a file later, the arm moves like crazy to read the file in its natural order) b) file external fragmentation, because of non-continuous data streams. If one downloads only one file, and there is no other disk writing activity on the system (while the file loads), there is no issue.
Lets imagine you'ld download 2 files with bittorrent... both are not preallocated. Lets say data packets coming in like this: packet_1_file1, packet_100_file2, packet_42_file1, packet_25_file2, packet_31_file1, packet_14_file1, packet_13_file2... since the files were not preallocated the OS would store them exactly in this order... so if you later want to read file1, the arm had constantly to skip parts of file2 (not too stressy, but in conjunction with the file internal fragmentation (a) its a lot more stressy). Preallocation helps to prevend a) and b).

Why use a cache?

Once you cache a file, it is not directly written to disk (even small caches can help). There is at least one write operation per incoming data block, but any write/read operation besides, is technically unecessary once the cache has the data. So if you e.g. upload a data block to different sources, you don't have to reread it every time from disk. Also writing parts of blocks (usually bittorrent clients download several at a time) is not so stressy, that means in a preallocated file, the arm does not have to jump in different positions in the file just to write every piece of new block data. (the block is to be completed in the cache and only then written to hdd). Even small RAM caches can be very usefull.
Ok Im now more confident with my pc..thanks alot cheers...
toru310 is offline   Reply With Quote