https://bugzilla.mindrot.org/show_bug.cgi?id=2927
Darren Tucker <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected], | |[email protected] Attachment #3212| |ok?([email protected]) Flags| | --- Comment #2 from Darren Tucker <[email protected]> --- 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. _______________________________________________ openssh-bugs mailing list [email protected] https://lists.mindrot.org/mailman/listinfo/openssh-bugs
