mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
netstack: don't allocate in XDP hot paths
In a redis-benchmark PING_INLINE test, this reduces allocations by 84%. PiperOrigin-RevId: 617542009
This commit is contained in:
committed by
gVisor bot
parent
8f1f1339bf
commit
1f6bd75648
@@ -301,8 +301,14 @@ func (ep *endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)
|
||||
// Copy packets into UMEM frame.
|
||||
frame := ep.control.UMEM.Get(batch[i])
|
||||
offset := 0
|
||||
for _, buf := range pkt.AsSlices() {
|
||||
offset += copy(frame[offset:], buf)
|
||||
var view *buffer.View
|
||||
views, pktOffset := pkt.AsViewList()
|
||||
for view = views.Front(); view != nil && pktOffset >= view.Size(); view = view.Next() {
|
||||
pktOffset -= view.Size()
|
||||
}
|
||||
offset += copy(frame[offset:], view.AsSlice()[pktOffset:])
|
||||
for view = view.Next(); view != nil; view = view.Next() {
|
||||
offset += copy(frame[offset:], view.AsSlice())
|
||||
}
|
||||
ep.control.TX.Set(index+uint32(i), batch[i])
|
||||
}
|
||||
@@ -385,7 +391,5 @@ func (ep *endpoint) dispatch() (bool, tcpip.Error) {
|
||||
// descriptors in the RX queue.
|
||||
ep.control.RX.Release(nReceived)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user