downloader: smaller ratelimit birst (#8435)

This commit is contained in:
Alex Sharov 2023-10-11 16:18:21 +07:00 committed by GitHub
parent 404719c292
commit fe263ae02e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,7 @@ const DefaultPieceSize = 2 * 1024 * 1024
// DefaultNetworkChunkSize - how much data request per 1 network call to peer.
// default: 16Kb
const DefaultNetworkChunkSize = 512 * 1024
const DefaultNetworkChunkSize = 256 * 1024
type Cfg struct {
ClientConfig *torrent.ClientConfig
@ -91,14 +91,9 @@ func New(dirs datadir.Dirs, version string, verbosity lg.Level, downloadRate, up
// check if ipv6 is enabled
torrentConfig.DisableIPv6 = !getIpv6Enabled()
// rates are divided by 2 - I don't know why it works, maybe bug inside torrent lib accounting
torrentConfig.UploadRateLimiter = rate.NewLimiter(rate.Limit(uploadRate.Bytes()), 2*DefaultNetworkChunkSize) // default: unlimited
torrentConfig.UploadRateLimiter = rate.NewLimiter(rate.Limit(uploadRate.Bytes()), DefaultNetworkChunkSize) // default: unlimited
if downloadRate.Bytes() < 500_000_000 {
b := 2 * DefaultNetworkChunkSize
if downloadRate.Bytes() > DefaultNetworkChunkSize {
b = int(2 * downloadRate.Bytes())
}
torrentConfig.DownloadRateLimiter = rate.NewLimiter(rate.Limit(downloadRate.Bytes()), b) // default: unlimited
torrentConfig.DownloadRateLimiter = rate.NewLimiter(rate.Limit(downloadRate.Bytes()), DefaultNetworkChunkSize) // default: unlimited
}
// debug