probe-lab / zikade

A Go implementation of the libp2p Kademlia DHT specification
Other
8 stars 3 forks source link

fix: garbage collect node handlers #71

Open iand opened 8 months ago

iand commented 8 months ago

Fixes a goroutine leak caused by not cleaning up idle node handlers. The map would grow to contain an entry and a corresponding work queue goroutine for every peer node ever contacted. This change keeps track of when a node handler was last used and removes ones that are deemed to be idle, cleaning up the goroutine at the same time.

Also reworks the network behaviour to follow the new behaviour notify/perform pattern and adds some configuration for logging and tracing.

Thunderdome testing shows goroutines remain steady with the fix and other resource utilization is the same or better.

Thunderdome test before fix: 10 reqs/sec

Thunderdome test after fix: 10 reqs/sec and 20 reqs/sec