cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

Fixed rate limiting for transfers that underun the buffer. Fixes #58 #59

Closed cavaliercoder closed 5 years ago

cavaliercoder commented 5 years ago

Some transfers, such as HTTPS have a consistently small chunk size (e.g. 16kb). Since these do not fill the default transfer buffer (32kb) on each read, the rate limiter becomes overly aggressive, limiting each read as though it would read 32kb.

gonejack commented 5 years ago

It works. however, when transfer buffer size get larger, it would be still hard to control the data flow rate accurately and smoothly by waiting.

In my previous experiences using a signal channel would work much ideally when we are doing batch download and sharing threshold to all goroutines:

image