mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-15 20:37:36 +02:00
size arena to match batch size
This commit is contained in:
@@ -37,6 +37,7 @@ type InterfaceConfig struct {
|
|||||||
DropLocalBroadcast bool
|
DropLocalBroadcast bool
|
||||||
DropMulticast bool
|
DropMulticast bool
|
||||||
routines int
|
routines int
|
||||||
|
batchSize int
|
||||||
MessageMetrics *MessageMetrics
|
MessageMetrics *MessageMetrics
|
||||||
version string
|
version string
|
||||||
relayManager *relayManager
|
relayManager *relayManager
|
||||||
@@ -70,6 +71,7 @@ type Interface struct {
|
|||||||
dropLocalBroadcast bool
|
dropLocalBroadcast bool
|
||||||
dropMulticast bool
|
dropMulticast bool
|
||||||
routines int
|
routines int
|
||||||
|
batchSize int
|
||||||
disconnectInvalid atomic.Bool
|
disconnectInvalid atomic.Bool
|
||||||
closed atomic.Bool
|
closed atomic.Bool
|
||||||
relayManager *relayManager
|
relayManager *relayManager
|
||||||
@@ -190,6 +192,7 @@ func NewInterface(ctx context.Context, c *InterfaceConfig) (*Interface, error) {
|
|||||||
dropLocalBroadcast: c.DropLocalBroadcast,
|
dropLocalBroadcast: c.DropLocalBroadcast,
|
||||||
dropMulticast: c.DropMulticast,
|
dropMulticast: c.DropMulticast,
|
||||||
routines: c.routines,
|
routines: c.routines,
|
||||||
|
batchSize: c.batchSize,
|
||||||
version: c.version,
|
version: c.version,
|
||||||
writers: make([]udp.Conn, c.routines),
|
writers: make([]udp.Conn, c.routines),
|
||||||
readers: make([]tio.Queue, c.routines),
|
readers: make([]tio.Queue, c.routines),
|
||||||
@@ -260,8 +263,8 @@ func (f *Interface) activate() error {
|
|||||||
}
|
}
|
||||||
f.readers = f.inside.Readers()
|
f.readers = f.inside.Readers()
|
||||||
for i := range f.readers {
|
for i := range f.readers {
|
||||||
arena := batch.NewArena(batch.DefaultPassthroughArenaCap)
|
arena := batch.NewArena(max(f.batchSize, 1) * udp.MTU)
|
||||||
f.batchers[i] = batch.NewPassthrough(f.readers[i], arena)
|
f.batchers[i] = batch.NewPassthrough(f.readers[i], f.batchSize, arena)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.wg.Add(1) // for us to wait on Close() to return
|
f.wg.Add(1) // for us to wait on Close() to return
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -215,6 +215,7 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
|
|||||||
DropLocalBroadcast: c.GetBool("tun.drop_local_broadcast", false),
|
DropLocalBroadcast: c.GetBool("tun.drop_local_broadcast", false),
|
||||||
DropMulticast: c.GetBool("tun.drop_multicast", false),
|
DropMulticast: c.GetBool("tun.drop_multicast", false),
|
||||||
routines: routines,
|
routines: routines,
|
||||||
|
batchSize: c.GetInt("listen.batch", 64),
|
||||||
MessageMetrics: messageMetrics,
|
MessageMetrics: messageMetrics,
|
||||||
version: buildVersion,
|
version: buildVersion,
|
||||||
relayManager: NewRelayManager(ctx, l, hostMap, c),
|
relayManager: NewRelayManager(ctx, l, hostMap, c),
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ const passthroughBaseNumSlots = 128
|
|||||||
// standalone Passthrough batcher: 128 slots × udp.MTU ≈ 1.1 MiB.
|
// standalone Passthrough batcher: 128 slots × udp.MTU ≈ 1.1 MiB.
|
||||||
const DefaultPassthroughArenaCap = passthroughBaseNumSlots * udp.MTU
|
const DefaultPassthroughArenaCap = passthroughBaseNumSlots * udp.MTU
|
||||||
|
|
||||||
func NewPassthrough(w io.Writer, arena *Arena) *Passthrough {
|
func NewPassthrough(w io.Writer, slots int, arena *Arena) *Passthrough {
|
||||||
return &Passthrough{
|
return &Passthrough{
|
||||||
out: w,
|
out: w,
|
||||||
slots: make([][]byte, 0, passthroughBaseNumSlots),
|
slots: make([][]byte, 0, slots),
|
||||||
arena: arena,
|
arena: arena,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user