[Bug 8375] New: rsync with bandwidth limit sometimes expend extra time

samba-bugs at samba.org samba-bugs at samba.org
Sat Aug 13 02:58:39 MDT 2011


           Summary: rsync with bandwidth limit sometimes expend extra time
           Product: rsync
           Version: 3.0.8
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: core
        AssignedTo: wayned at samba.org
        ReportedBy: fbmoser at gmail.com
         QAContact: rsync-qa at samba.org

If you transfer the arq1 file with 2,100 Kbytes using the option --bwlimit=16
the rsync expends about 131 seconds. This time is correct because the
calculated time is 131.25 seconds.

But when you transfer the arq2 file with 2,200 Kbytes, using the same option
--bwlimit=16 the rsync expends about 268 seconds that is about 130 seconds more
that the calculated time of 137.5 seconds.

The test can be made transfering the files to the same machine and using the
time command to measure the runtime.

The next lines demonstrates the problem: 

$ time rsync --bwlimit=16 /tmp/arq1 localhost::test

real    2m11.431s
user    0m0.001s
sys     0m0.014s

$ time rsync --bwlimit=16 /tmp/arq2 localhost::test

real    4m28.598s
user    0m0.000s
sys     0m0.020s

Using the source code from
http://pkgs.repoforge.org/rsync/rsync-3.0.8-1.rfx.src.rpm was possible to
discover the solution of the problem.

The next lines show the modifications needed in io.c file to resolve the

$ diff -u io.c io.c-MOSER
--- io.c        2010-06-30 13:17:26.000000000 -0300
+++ io.c-MOSER  2011-08-12 22:29:41.000000000 -0300
@@ -1402,7 +1402,7 @@
        if (prior_tv.tv_sec) {
                elapsed_usec = (start_tv.tv_sec - prior_tv.tv_sec) * ONE_SEC
                             + (start_tv.tv_usec - prior_tv.tv_usec);
-               total_written -= elapsed_usec * bwlimit / (ONE_SEC/1024);
+               total_written -= ((long long)((long long)elapsed_usec *
bwlimit) / (ONE_SEC/1024));
                if (total_written < 0)
                        total_written = 0;

Thank you.

Francisco Moser

Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the rsync mailing list