probe-lab / zikade

A Go implementation of the libp2p Kademlia DHT specification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimize reading libp2p messages with sync.Pool buffers

guillaumemichel opened this issue · comments

the libp2p endpoint doesn't yet make use of sync.Pool to optimize memory allocations when writing/reading messages to/from a libp2p stream. This seems to be an easy performance improvement.

go-libp2p-kad-dht is using sync.Pool (see https://github.com/libp2p/go-libp2p-kad-dht/blob/978cb74f5fdf846e09d5769bb4dfb9f962135c38/internal/net/message_manager.go#L360-L368)

References

https://github.com/plprobelab/go-kademlia/blob/main/network/endpoint/libp2pendpoint/libp2pendpoint.go

Will move issue to go-libp2p-kad-dht for KadDHT in v2