mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 22:03:41 +00:00
perf(http): use 64 KiB connection read buffers (#1588)
This commit is contained in:
1 parent
de65149b29
commit
47cafb7575
1 file changed
+8
-3
@@ -39,6 +39,11 @@ const (
|
|||||||
stealMinChunkSize = 512 * 1024 // Min steal size: 512KB (avoid tiny chunks)
|
stealMinChunkSize = 512 * 1024 // Min steal size: 512KB (avoid tiny chunks)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// connReadBufferSize is the read buffer each connection allocates once and
|
||||||
|
// reuses for its lifetime. 64 KiB keeps per-read overhead low on fast links;
|
||||||
|
// at 256 connections it is 16 MiB per task.
|
||||||
|
const connReadBufferSize = 64 * 1024
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errRangeRequestIgnored = errors.New("server ignored HTTP range request")
|
errRangeRequestIgnored = errors.New("server ignored HTTP range request")
|
||||||
errInvalidRangeResponse = errors.New("invalid HTTP range response")
|
errInvalidRangeResponse = errors.New("invalid HTTP range response")
|
||||||
@@ -1136,7 +1141,7 @@ func (f *Fetcher) runConnection(conn *connection) {
|
|||||||
|
|
||||||
// Use fast-fail client for quick retry during download phase
|
// Use fast-fail client for quick retry during download phase
|
||||||
client := f.buildFastFailClient()
|
client := f.buildFastFailClient()
|
||||||
buf := make([]byte, 8192)
|
buf := make([]byte, connReadBufferSize)
|
||||||
|
|
||||||
retries := 0
|
retries := 0
|
||||||
f.connMu.Lock()
|
f.connMu.Lock()
|
||||||
@@ -1798,7 +1803,7 @@ func (f *Fetcher) runConnectionWithResolveResp(conn *connection) {
|
|||||||
conn.State = connConnecting
|
conn.State = connConnecting
|
||||||
f.connMu.Unlock()
|
f.connMu.Unlock()
|
||||||
|
|
||||||
buf := make([]byte, 8192)
|
buf := make([]byte, connReadBufferSize)
|
||||||
|
|
||||||
// Get the resolve response
|
// Get the resolve response
|
||||||
f.resolveRespLock.Lock()
|
f.resolveRespLock.Lock()
|
||||||
@@ -1892,7 +1897,7 @@ func (f *Fetcher) runConnectionWithResolveResp(conn *connection) {
|
|||||||
func (f *Fetcher) runConnectionFallback(conn *connection) {
|
func (f *Fetcher) runConnectionFallback(conn *connection) {
|
||||||
// Use fast-fail client for quick retry during download phase
|
// Use fast-fail client for quick retry during download phase
|
||||||
client := f.buildFastFailClient()
|
client := f.buildFastFailClient()
|
||||||
buf := make([]byte, 8192)
|
buf := make([]byte, connReadBufferSize)
|
||||||
|
|
||||||
retries := 0
|
retries := 0
|
||||||
countedRetries := 0
|
countedRetries := 0
|
||||||
|
|||||||
Reference in new issue
Block a user