From 266fe0637fcd03d6aefa6a2ff28cdef9a82867ba Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 25 May 2022 12:39:34 +0300 Subject: [PATCH] adjust RA --- server/torr/preload.go | 12 ++++++------ server/torr/storage/torrstor/cache.go | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/torr/preload.go b/server/torr/preload.go index 86bb75f..6e9a2be 100644 --- a/server/torr/preload.go +++ b/server/torr/preload.go @@ -63,17 +63,17 @@ func (t *Torrent) Preload(index int, size int64) { } }() - // mb5 -> 8/16 MB - mb5 := int64(t.Info().PieceLength) - if mb5 < 8*1024*1024 { - mb5 = 8 * 1024 * 1024 + // startend -> 8/16 MB + startend := int64(t.Info().PieceLength) + if startend < 8*1024*1024 { + startend = 8 * 1024 * 1024 } readerStart := file.NewReader() defer readerStart.Close() readerStart.SetResponsive() readerStart.SetReadahead(0) - readerStartEnd := size - mb5 + readerStartEnd := size - startend if readerStartEnd < 0 { // Если конец начального ридера оказался за началом @@ -84,7 +84,7 @@ func (t *Torrent) Preload(index int, size int64) { readerStartEnd = file.Length() } - readerEndStart := file.Length() - mb5 + readerEndStart := file.Length() - startend readerEndEnd := file.Length() var wa sync.WaitGroup diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index 1a5f56b..9326cd8 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -255,9 +255,9 @@ func (c *Cache) getRemPieces() []*Piece { readerPos := r.getReaderPiece() readerRAHPos := r.getReaderRAHPiece() end := r.getPiecesRange().End - count := int(16 * 1024 * 1024 / c.pieceLength * 5) // 80 MB - if count > 40 { - count = 40 + count := int(16 * 1024 * 1024 * 4 / c.pieceLength) // 64 MB window + if count > 64 { + count = 64 } limit := 0 for i := readerPos; i < end && limit < count; i++ {