size arena to match batch size

This commit is contained in:
JackDoan
2026-05-13 15:07:21 -05:00
parent d1d8439b8e
commit 0874bf2e23
3 changed files with 8 additions and 4 deletions

View File

@@ -37,6 +37,7 @@ type InterfaceConfig struct {
DropLocalBroadcast bool
DropMulticast bool
routines int
batchSize int
MessageMetrics *MessageMetrics
version string
relayManager *relayManager
@@ -70,6 +71,7 @@ type Interface struct {
dropLocalBroadcast bool
dropMulticast bool
routines int
batchSize int
disconnectInvalid atomic.Bool
closed atomic.Bool
relayManager *relayManager
@@ -190,6 +192,7 @@ func NewInterface(ctx context.Context, c *InterfaceConfig) (*Interface, error) {
dropLocalBroadcast: c.DropLocalBroadcast,
dropMulticast: c.DropMulticast,
routines: c.routines,
batchSize: c.batchSize,
version: c.version,
writers: make([]udp.Conn, c.routines),
readers: make([]tio.Queue, c.routines),
@@ -260,8 +263,8 @@ func (f *Interface) activate() error {
}
f.readers = f.inside.Readers()
for i := range f.readers {
arena := batch.NewArena(batch.DefaultPassthroughArenaCap)
f.batchers[i] = batch.NewPassthrough(f.readers[i], arena)
arena := batch.NewArena(max(f.batchSize, 1) * udp.MTU)
f.batchers[i] = batch.NewPassthrough(f.readers[i], f.batchSize, arena)
}
f.wg.Add(1) // for us to wait on Close() to return