What is the default block size in rsync?

If I execute rsync without providing --block-size option then what does it ue for a block size?

I am using rsync on a Linux platform.


From the rsync manual:

-B, --block-size=BLOCKSIZE

This forces the block size used in rsync’s delta-transfer algorithm to a fixed value. It is normally selected based on the size of each file being updated. See the technical report for details.

The technical report is available at https://rsync.samba.org/tech_report/ although it is quite old and does not go into detail about how the block size is selected, only that "that values of S between 500 and 1000 are quite good for most purposes" (these values are not what actually used in the code, see below).

A couple of comments in the actual source code reveals that the square root of the file size is used as the block size (rounded to a multiple of 8):

 * set (initialize) the size entries in the per-file sum_struct
 * calculating dynamic block and checksum sizes.
 * This is only called from generate_and_send_sums() but is a separate
 * function to encapsulate the logic.
 * The block size is a rounded square root of file length.
 * The checksum size is determined according to:
 *     blocksum_bits = BLOCKSUM_BIAS + 2*log2(file_len) - log2(block_len)
 * provided by Donovan Baarda which gives a probability of rsync
 * algorithm corrupting data and falling back using the whole md4
 * checksums.
 * This might be made one of several selectable heuristics.
static void sum_sizes_sqroot(struct sum_struct *sum, int64 len)


        else {
            blength = 0;
            do {
                blength |= c;
                if (len < (int64)blength * blength)
                    blength &= ~c;
                c >>= 1;
            } while (c >= 8);   /* round to multiple of 8 */
            blength = MAX(blength, BLOCK_SIZE);

The block size chosen is independent of the type of Unix being used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.