question about --bwlimit=
Wayne Davison
wayned at samba.org
Wed May 26 10:09:59 GMT 2004
On Wed, May 26, 2004 at 09:42:55AM +0200, Paul Slootman wrote:
> What is a typical value for "len-total"?
The most typical value is "4". Once a file starts to transfer, values
are typically several K (I've seen up to 32K, but only on larger files).
I had been thinking that a better algorithm for setting the max value
correctly for both large and small values of bwlimit would be good.
Maybe something like this:
--- io.c 15 May 2004 19:31:10 -0000 1.121
+++ io.c 26 May 2004 09:48:27 -0000
@@ -47,6 +47,7 @@ static time_t last_io;
static int no_flush;
extern int bwlimit;
+extern size_t bwlimit_writemax;
extern int verbose;
extern int io_timeout;
extern int am_server;
@@ -812,6 +813,8 @@ static void writefd_unbuffered(int fd,ch
if (FD_ISSET(fd, &w_fds)) {
int ret;
size_t n = len-total;
+ if (bwlimit && n > bwlimit_writemax)
+ n = bwlimit_writemax;
ret = write(fd,buf+total,n);
if (ret < 0) {
--- options.c 24 May 2004 18:38:05 -0000 1.152
+++ options.c 26 May 2004 09:48:27 -0000
@@ -83,6 +83,7 @@ int safe_symlinks = 0;
int copy_unsafe_links = 0;
int size_only = 0;
int bwlimit = 0;
+size_t bwlimit_writemax = 0;
int delete_after = 0;
int only_existing = 0;
int opt_ignore_existing = 0;
@@ -728,6 +729,12 @@ int parse_arguments(int *argc, const cha
if (do_progress && !verbose)
verbose = 1;
+ if (bwlimit) {
+ bwlimit_writemax = (size_t)bwlimit * 128;
+ if (bwlimit_writemax < 512)
+ bwlimit_writemax = 512;
+ }
+
if (files_from) {
char *colon;
if (*argc != 2 && !(am_server && am_sender && *argc == 1)) {
This makes the calculation more like the original for larger bwlimit
values, but tries to avoid making really small TCP packets for smaller
bwlimit values (which was a concern someone expressed a while back).
The above logic for setting bwlimit_writemax should probably be tuned
with actual testing (it's currently just an arbitrary "this looks good"
choice).
..wayne..
More information about the rsync
mailing list