perf(bond): убрать аллокацию на чанк в copyTCPToBond
writeBondFrame пишет синхронно через w.Write, поэтому слайс буфера чтения безопасно передавать напрямую. Убирает одну аллокацию+копию на TCP-чанк на горячем пути upload.
This commit is contained in:
1 parent
d0dabeec67
commit
085b719be7
1 file changed
+1
-3
+1
-3
@@ -1794,9 +1794,7 @@ func copyTCPToBond(ctx context.Context, connID uint64, tcpConn net.Conn, lanes [
|
||||
for {
|
||||
n, err := tcpConn.Read(buf)
|
||||
if n > 0 {
|
||||
data := make([]byte, n)
|
||||
copy(data, buf[:n])
|
||||
lane, writeErr := writeBondFrameToNextLane(ctx, lanes, bondFrameData, seq, data, &laneIdx)
|
||||
lane, writeErr := writeBondFrameToNextLane(ctx, lanes, bondFrameData, seq, buf[:n], &laneIdx)
|
||||
if writeErr != nil {
|
||||
log.Printf("[bond %d] write data error: %v", connID, writeErr)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user