Switch connAddr (udp map key) from string to a struct that allocates less. Reduce some other allocations. Use larger channel buffers to reduce backpressure from runtime jitter.

This commit is contained in:
Arceliar 2018-01-13 07:26:26 -06:00
parent ef1e0c902f
commit 75965b6da4
6 changed files with 60 additions and 28 deletions

View file

@ -40,7 +40,7 @@ type router struct {
func (r *router) init(core *Core) {
r.core = core
r.addr = *address_addrForNodeID(&r.core.dht.nodeID)
in := make(chan []byte, 1) // TODO something better than this...
in := make(chan []byte, 1024) // TODO something better than this...
p := r.core.peers.newPeer(&r.core.boxPub, &r.core.sigPub) //, out, in)
// TODO set in/out functions on the new peer...
p.out = func(packet []byte) { in <- packet } // FIXME in theory it blocks...
@ -50,8 +50,8 @@ func (r *router) init(core *Core) {
// TODO attach these to the tun
// Maybe that's the core's job...
// It creates tun, creates the router, creates channels, sets them?
recv := make(chan []byte, 1)
send := make(chan []byte, 1)
recv := make(chan []byte, 1024)
send := make(chan []byte, 1024)
r.recv = recv
r.send = send
r.core.tun.recv = recv