diff --git a/interface.go b/interface.go index cefd330..c68f3f9 100644 --- a/interface.go +++ b/interface.go @@ -313,7 +313,7 @@ func (f *Interface) listenOut(q int) { func (f *Interface) listenIn(reader overlay.TunDev, queueNum int) { runtime.LockOSThread() - const batch = 64 + const batch = 128 originalPackets := make([][]byte, batch) //todo batch config for i := 0; i < batch; i++ { originalPackets[i] = make([]byte, 0xffff) diff --git a/udp/udp_linux.go b/udp/udp_linux.go index 187e411..752f219 100644 --- a/udp/udp_linux.go +++ b/udp/udp_linux.go @@ -211,7 +211,7 @@ func (u *StdConn) WriteBatch(pkts []*packet.Packet) (int, error) { iovs := make([][]iovec, 0, len(pkts)) sent := 0 - + const maxIovLen = 48 var mostRecentPkt *packet.Packet //segmenting := false idx := 0 @@ -221,7 +221,7 @@ func (u *StdConn) WriteBatch(pkts []*packet.Packet) (int, error) { continue } lastIdx := idx - 1 - if mostRecentPkt != nil && pkt.CompatibleForSegmentationWith(mostRecentPkt) && msgs[lastIdx].Hdr.Iovlen < 4 { + if mostRecentPkt != nil && pkt.CompatibleForSegmentationWith(mostRecentPkt) && msgs[lastIdx].Hdr.Iovlen < maxIovLen { //todo math this more good msgs[lastIdx].Hdr.Controllen = uint64(len(mostRecentPkt.Control)) msgs[lastIdx].Hdr.Control = &mostRecentPkt.Control[0] @@ -233,7 +233,7 @@ func (u *StdConn) WriteBatch(pkts []*packet.Packet) (int, error) { mostRecentPkt.SetSegSizeForTX() } else { msgs = append(msgs, rawMessage{}) - iovs = append(iovs, make([]iovec, 1, 8)) //todo + iovs = append(iovs, make([]iovec, 1, maxIovLen)) //todo iovs[idx][0] = iovec{ Base: &pkt.Payload[0], Len: uint64(len(pkt.Payload)),