libp2p / universal-connectivity

Realtime decentralised chat with libp2p showing ubiquitous peer-to-peer connectivity between multiple programming languages (Go, Rust, TypeScript) and runtimes (Web, native binary) using QUIC, WebRTC and WebTransport
https://universal-connectivity.vercel.app
Other
87 stars 32 forks source link

Rust peer exhausting resources #135

Open 2color opened 5 months ago

2color commented 5 months ago

Problem

Every since https://github.com/libp2p/universal-connectivity/pull/114 was merged and the Rust peer is now part of the IPFS Kademlia DHT, it's resource consumption has spiked significantly. It's running on a pretty beefy machine (32GB RAM), yet manages to eat up the CPU cycles from the moment it starts:

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   1687 root      20   0 1384924   1.0g  33812 S 650.3   3.3  11:30.25 rust-libp2p-web
   1718 root      20   0 2651788 131636  22300 S   2.7   0.4   0:11.17 go-peer

Especially when compared to the go-peer (which also joins the IPFS DHT as a DHT Server)

Potential solutions

It's probably sensible to figure out why the Rust peer is consuming so much resources in order to come up with solutions. We know that this problem started every since it joined the IPFS DHT and connected to the bootstrap nodes.

It may be sensible to instrument the code to figure out why this is happening, in addition to adding some connection limits and having a look at https://github.com/libp2p/rust-libp2p/tree/master/misc/server as a comparison rust-libp2p DHT Server.

2color commented 5 months ago

@p-shahi Any thoughts?