mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-23 12:53:43 +00:00
refactor(buffer): Optimizes TCP and HTTP streaming request processing using a buffer pool.
Replaces the fixed-size buffers in `FrameHandler` and `Handler` with dynamic buffers obtained from the buffer pool, to reduce memory allocation and improve performance. Also updates the logo path in the README to match the new resource directory structure.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<p align="center">
|
||||
<img src="images/logo.png" alt="Drip Logo" width="200" />
|
||||
<img src="assets/logo.png" alt="Drip Logo" width="200" />
|
||||
</p>
|
||||
|
||||
<h1 align="center">Drip</h1>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<p align="center">
|
||||
<img src="images/logo.png" alt="Drip Logo" width="200" />
|
||||
<img src="assets/logo.png" alt="Drip Logo" width="200" />
|
||||
</p>
|
||||
|
||||
<h1 align="center">Drip</h1>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
@@ -354,7 +354,9 @@ func (h *FrameHandler) adaptiveHTTPResponse(streamID, requestID string, resp *ht
|
||||
|
||||
// Buffer for initial read
|
||||
buffer := make([]byte, 0, threshold)
|
||||
tempBuf := make([]byte, 32*1024) // 32KB read chunks
|
||||
tempBufPtr := h.bufferPool.Get(pool.SizeMedium)
|
||||
defer h.bufferPool.Put(tempBufPtr)
|
||||
tempBuf := (*tempBufPtr)[:pool.SizeMedium]
|
||||
|
||||
var totalRead int64
|
||||
var hitThreshold bool
|
||||
|
||||
@@ -312,7 +312,9 @@ func (h *Handler) streamLargeRequest(w http.ResponseWriter, r *http.Request, tra
|
||||
}
|
||||
}
|
||||
|
||||
buffer := make([]byte, 32*1024)
|
||||
streamBufPtr := h.bufferPool.GetMedium()
|
||||
defer h.bufferPool.PutMedium(streamBufPtr)
|
||||
buffer := (*streamBufPtr)[:pool.MediumBufferSize]
|
||||
for {
|
||||
n, readErr := r.Body.Read(buffer)
|
||||
if n > 0 {
|
||||
|
||||
Reference in New Issue
Block a user