diff options
Diffstat (limited to 'weed')
| -rw-r--r-- | weed/filer/stream.go | 18 | ||||
| -rw-r--r-- | weed/util/http/client/http_client.go | 5 |
2 files changed, 22 insertions, 1 deletions
diff --git a/weed/filer/stream.go b/weed/filer/stream.go index b2ee00555..b7857041c 100644 --- a/weed/filer/stream.go +++ b/weed/filer/stream.go @@ -374,6 +374,24 @@ func (c *ChunkStreamReader) fetchChunkToBuffer(chunkView *ChunkView) error { glog.V(1).Infof("operation LookupFileId %s failed, err: %v", chunkView.FileId, err) return err } + + // Fast path: for full, plain chunks, read directly into a single buffer to avoid + // the streaming loop (which stages 64KB at a time and adds an extra copy). + if chunkView.CipherKey == nil && !chunkView.IsGzipped && chunkView.IsFullChunk() { + buf := make([]byte, chunkView.ViewSize) + n, fetchErr := util_http.RetriedFetchChunkData(context.Background(), buf, urlStrings, nil, false, true, chunkView.OffsetInChunk, chunkView.FileId) + if fetchErr == nil && n == len(buf) { + c.buffer = buf + c.bufferOffset = chunkView.ViewOffset + c.chunk = chunkView.FileId + return nil + } + // Fall back to the streaming path on partial fill or error + if fetchErr != nil { + glog.V(1).Infof("read %s direct failed, err: %v, falling back to stream", chunkView.FileId, fetchErr) + } + } + var buffer bytes.Buffer var shouldRetry bool jwt := JwtForVolumeServer(chunkView.FileId) diff --git a/weed/util/http/client/http_client.go b/weed/util/http/client/http_client.go index d1d2f5c56..0494fd04b 100644 --- a/weed/util/http/client/http_client.go +++ b/weed/util/http/client/http_client.go @@ -130,7 +130,10 @@ func NewHttpClient(clientName ClientName, opts ...HttpClientOpt) (*HTTPClient, e httpClient.Transport = &http.Transport{ MaxIdleConns: 1024, MaxIdleConnsPerHost: 1024, - TLSClientConfig: tlsConfig, + // Allow truly parallel per-host connections and avoid HTTP/2 multiplexing + MaxConnsPerHost: 0, // unlimited + ForceAttemptHTTP2: false, // disable HTTP/2 to avoid implicit single-connection multiplexing + TLSClientConfig: tlsConfig, } httpClient.Client = &http.Client{ Transport: httpClient.Transport, |
