Rsync is efficient at transferring diffs across the wire, but how efficient is it at updating the remote file itself (in terms of disk operations)? If, for example, you have a 500MB file (say an ISO) whose modification consists solely of a few bytes added on to the beginning of the file. Will it create an entirely new 500MB file? Or will it somehow know how to insert the bytes at the beginning of the remote file? If it is capable of the latter, how does it do it in terms of C calls, considering there is no C call to do inserts into a file? write(), while it can be positioned with lseek(), only overwrites and cannot insert.
On Mon 07 Mar 2005, andy@neotitans.com wrote:> > If, for example, you have a 500MB file (say an ISO) whose modification > consists solely of a few bytes added on to the beginning of the file. > > Will it create an entirely new 500MB file? Or will it somehow know how to > insert the bytes at the beginning of the remote file?Inserting bytes at the beginning of a file can't be done, at least not on unix-like systems. That can only be done by copying the file. Paul Slootman
Paul Slootman wrote:> Inserting bytes at the beginning of a file can't be done, at > least not on unix-like systems. That can only be done by copying > the file.Ok. What about if there were some inserts in the middle of the hypothetical 500MB file, starting for example at the 450 millionth up to the 460 millionth byte (so it's now 510MB). Does rsync: a) create a new file b) have the ability to insert the bytes into the middle of the backup file c) copy every byte from the 450th MB to the end of the original file (510thMB) into a temp file, truncate the destination file from the 450th MB onwards and then append the contents of the temp file there. d) do something other than the above Finally, what about the case where changes only appear at the end of the file? Is rsync smart enough to just append to the destination file?