On Wed, Jun 18, 2003 at 09:09:59PM +1000, Martin Pool wrote: > On 17 Jun 2003, Rogier Wolff <[EMAIL PROTECTED]> wrote: > > > > Oops. Missed one line in the last patch.... > > Thankyou. That looks good. > > If we're going to make this more accurate it might be worthwhile to > actually look at how long we really did sleep for, and use that to > adjust time_to_sleep rather than resetting to zero.
That would have to be a platform specific thing since not all systems modify the timeout value to reflect the amount of time not slept. Nevertheless that is a nice idea. > Also I'd prefer the variable be called micros_to_sleep or > us_to_sleep. Small point I know. I'm not too keen on forcing the minimum sleep to be 100ms. That is just too coarse for my taste and tends produce fits-and-starts stalling on very slow links. This should be balanced with the "Smoother bandwidth limiting" thread. Perhaps setting a minimum sleep to 10ms or a period based on the value of bwlimit. > > diff -ur rsync-2.5.6.orig/io.c rsync-2.5.6/io.c > > +++ rsync-2.5.6/io.c Tue Jun 17 23:43:49 2003 > > @@ -416,10 +416,19 @@ > > * use a bit less bandwidth than specified, because it doesn't make up > > * for slow periods. But arguably this is a feature. In addition, we > > * ought to take the time used to write the data into account. > > + * > > + * During some phases of big transfers (file XXX is uptodate) this is > > + * called with a small bytes_written every time. As the kernel has to > > + * round small waits up to guarantee that we actually wait at least > > + * the requested number of microseconds, this can become grossly > > + * inaccurate. We therefore keep a cumulating number of microseconds > > + * to wait, and only actually perform the sleep when the rouding > > + * becomes insignificant. (less than 10%) -- REW. > > **/ > > static void sleep_for_bwlimit(int bytes_written) > > { > > struct timeval tv; > > + static int time_to_sleep = 0; > > > > if (!bwlimit) > > return; > > @@ -427,9 +436,13 @@ > > assert(bytes_written > 0); > > assert(bwlimit > 0); > > > > - tv.tv_usec = bytes_written * 1000 / bwlimit; > > - tv.tv_sec = tv.tv_usec / 1000000; > > - tv.tv_usec = tv.tv_usec % 1000000; > > + time_to_sleep += bytes_written * 1000 / bwlimit; > > + > > + if (time_to_sleep < 100000) return; > > + > > + tv.tv_sec = time_to_sleep / 1000000; > > + tv.tv_usec = time_to_sleep % 1000000; > > + time_to_sleep = 0; > > > > select(0, NULL, NULL, NULL, &tv); > > } > > -- > Martin > -- > To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync > Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html > -- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: [EMAIL PROTECTED] Remember Cernan and Schmitt -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html