[Bug 2927] scp -l can't limit the bandwidth at the first several seconds
bugzilla-daemon at bugzilla.mindrot.org
bugzilla-daemon at bugzilla.mindrot.org
Fri Dec 7 15:02:02 AEDT 2018
https://bugzilla.mindrot.org/show_bug.cgi?id=2927
Darren Tucker <dtucker at dtucker.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |djm at mindrot.org,
| |dtucker at dtucker.net
Attachment #3212| |ok?(djm at mindrot.org)
Flags| |
--- Comment #2 from Darren Tucker <dtucker at dtucker.net> ---
Created attachment 3212
--> https://bugzilla.mindrot.org/attachment.cgi?id=3212&action=edit
Fix scp bwlimit calculation.
Looking at the misc.c:bandwidth* functions I think there's two
problems.
> bandwidth_limit(struct bwlimit *bw, size_t read_len)
> { [...]
> if (!timerisset(&bw->bwstart)) {
> monotime_tv(&bw->bwstart);
> return;
> }
> bw->lamt += read_len;
The first (minor) problem: the first buffer written (16k, by default)
is not accounted for at all because it returns before it gets to the
code that accounts for it.
> if (bw->lamt < bw->thresh)
> return;
This is the main problem: bw->thresh is set to the bandwidth limit (in
kbit/s), which means that for any non-trivial bandwidth limit it'll
receive many writes before it even considers inserting a delay, so you
get an initial burst followed by pause until the average drops back to
the intended rate.
This patch moves accounting so the first block is accounted for, and
sets the initial threshold such that it'll start computing the rate on
the second and subsequent blocks.
Without patch:
$ ./scp -l 1000 /tmp/1MB localhost:/dev/null
1MB 0% 0 0.0KB/s --:-- ETA
1MB 100% 1024KB 1.0MB/s 00:01
1MB 100% 1024KB 511.8KB/s 00:02
1MB 100% 1024KB 341.2KB/s 00:03
1MB 100% 1024KB 255.9KB/s 00:04
1MB 100% 1024KB 204.7KB/s 00:05
1MB 100% 1024KB 170.6KB/s 00:06
1MB 100% 1024KB 146.2KB/s 00:07
1MB 100% 1024KB 127.9KB/s 00:08
With patch:
$ ./scp -l 1000 /tmp/1MB localhost:/dev/null
1MB 0% 0 0.0KB/s --:-- ETA
1MB 12% 128KB 127.9KB/s 00:07 ETA
1MB 25% 256KB 127.9KB/s 00:06 ETA
1MB 37% 384KB 127.9KB/s 00:05 ETA
1MB 50% 512KB 127.9KB/s 00:04 ETA
1MB 60% 624KB 126.3KB/s 00:03 ETA
1MB 73% 752KB 126.5KB/s 00:02 ETA
1MB 85% 880KB 126.6KB/s 00:01 ETA
1MB 98% 1008KB 126.8KB/s 00:00 ETA
1MB 100% 1024KB 124.6KB/s 00:08
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list