libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.48k stars 928 forks source link

Reduce dependency tree #3515

Open thomaseizinger opened 1 year ago

thomaseizinger commented 1 year ago

I'll record various efforts in here to reduce the size of our dependency tree where possible.

- [ ] https://github.com/libp2p/rust-libp2p/pull/3514
- [ ] https://github.com/libp2p/rust-libp2p/pull/3513
- [ ] https://github.com/libp2p/rust-libp2p/pull/3512
- [ ] https://github.com/libp2p/rust-libp2p/pull/3510
- [ ] https://github.com/webrtc-rs/webrtc/pull/411
- [ ] https://github.com/libp2p/rust-libp2p/pull/3312
- [ ] `combine` is only brought in by `redis` through `interop-test`
- [ ] https://github.com/libp2p/rust-libp2p/issues/3659
- [ ] https://github.com/libp2p/rust-libp2p/issues/4449

More suggestions welcome, a good place to start is a timings report by cargo of the entire workspace (minus dev-dependencies): cargo build --workspace --all-features --timings. Once you have identified a (ideally heavy) dependency that we might not need, investigate with cargo tree -i -p <dependency> where it comes from.

tbu- commented 1 year ago

Might it be possible to get rid of the async-std (optional) dependency? I'd guess the ecosystem has moved on to tokio these days, with the last commit in async-std being 9 months ago: https://github.com/async-rs/async-std/commit/bf316b095c176c8738c6401cc62d0bc389c88961.

I think this could help cutting down some more dependencies as well.

thomaseizinger commented 1 year ago

I am not following the async-std development but I'd consider that one too established to remove.

Plus, it is optional as you said. I think it would be more fruitful to investigate for dependencies in our protocol crates like yamux, gossipsub or kademlia.

thomaseizinger commented 1 year ago

Might it be possible to get rid of the async-std (optional) dependency? I'd guess the ecosystem has moved on to tokio these days, with the last commit in async-std being 9 months ago: async-rs/async-std@bf316b0.

I think this could help cutting down some more dependencies as well.

We can cut down some dependencies by moving all our tests and examples to tokio. async-std is heavily feature-flagged, meaning we can reduce our dependencies by only activating the bare minimum features needed in the various transports and libp2p-swarm.