perf(http): use 64 KiB connection read buffers (#1588)

This commit is contained in:
Arpit Khandelwal authored and GitHub committed 2026-10-21 14:19:01 +08:00
1 parent de65149b29
commit 47cafb7575
1 file changed
+8 -3
+8 -3
View File
@@ -39,6 +39,11 @@ const (
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 (
errRangeRequestIgnored = errors.New("server ignored HTTP range request")
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
client := f.buildFastFailClient()
buf := make([]byte, 8192)
buf := make([]byte, connReadBufferSize)
retries := 0
f.connMu.Lock()
@@ -1798,7 +1803,7 @@ func (f *Fetcher) runConnectionWithResolveResp(conn *connection) {
conn.State = connConnecting
f.connMu.Unlock()
buf := make([]byte, 8192)
buf := make([]byte, connReadBufferSize)
// Get the resolve response
f.resolveRespLock.Lock()
@@ -1892,7 +1897,7 @@ func (f *Fetcher) runConnectionWithResolveResp(conn *connection) {
func (f *Fetcher) runConnectionFallback(conn *connection) {
// Use fast-fail client for quick retry during download phase
client := f.buildFastFailClient()
buf := make([]byte, 8192)
buf := make([]byte, connReadBufferSize)
retries := 0
countedRetries := 0