rsync 中的默认块大小是多少?
如果我在不提供--block-size
选项的情况下执行 rsync 那么块大小有什么用?
我在 Linux 平台上使用 rsync。
小智 5
--block-size=BLOCKSIZE
在命令行上指定,则使用该块大小。因此,根据新版本rsync
,根据源代码常量中的定义,块大小范围在 700 字节到 131KB 之间。
从rsync
手册中:
\n\n\n\n\n
-B
,--block-size=BLOCKSIZE
这会强制 rsync\xe2\x80\x99s 增量传输\n 算法中使用的块大小为固定值。通常根据要更新的每个文件的大小来选择。详细信息请参阅技术报告\n。
\n
该技术报告可在https://rsync.samba.org/tech_report/上找到,尽管它很旧,并且没有详细介绍如何选择块大小,只是“S 的值在 500 到 1000 之间是相当大的”。适用于大多数用途”(这些值不是代码中实际使用的值,请参见下文)。
\n\n实际源代码中的几条注释表明文件大小的平方根用作块大小(四舍五入到 8 的倍数):
\n\n/*\n * set (initialize) the size entries in the per-file sum_struct\n * calculating dynamic block and checksum sizes.\n *\n * This is only called from generate_and_send_sums() but is a separate\n * function to encapsulate the logic.\n *\n * The block size is a rounded square root of file length.\n *\n * The checksum size is determined according to:\n * blocksum_bits = BLOCKSUM_BIAS + 2*log2(file_len) - log2(block_len)\n * provided by Donovan Baarda which gives a probability of rsync\n * algorithm corrupting data and falling back using the whole md4\n * checksums.\n *\n * This might be made one of several selectable heuristics.\n */\nstatic void sum_sizes_sqroot(struct sum_struct *sum, int64 len)\n{\n
Run Code Online (Sandbox Code Playgroud)\n\n[...]
\n\n else {\n blength = 0;\n do {\n blength |= c;\n if (len < (int64)blength * blength)\n blength &= ~c;\n c >>= 1;\n } while (c >= 8); /* round to multiple of 8 */\n blength = MAX(blength, BLOCK_SIZE);\n }\n
Run Code Online (Sandbox Code Playgroud)\n\n所选择的块大小与所使用的 Unix 类型无关。
\n