Files
pezkuwi-subxt/polkadot/node/subsystem-bench/Cargo.toml
T
Aaro Altonen 80616f6d03 Integrate litep2p into Polkadot SDK (#2944)
[litep2p](https://github.com/altonen/litep2p) is a libp2p-compatible P2P
networking library. It supports all of the features of `rust-libp2p`
that are currently being utilized by Polkadot SDK.

Compared to `rust-libp2p`, `litep2p` has a quite different architecture
which is why the new `litep2p` network backend is only able to use a
little of the existing code in `sc-network`. The design has been mainly
influenced by how we'd wish to structure our networking-related code in
Polkadot SDK: independent higher-levels protocols directly communicating
with the network over links that support bidirectional backpressure. A
good example would be `NotificationHandle`/`RequestResponseHandle`
abstractions which allow, e.g., `SyncingEngine` to directly communicate
with peers to announce/request blocks.

I've tried running `polkadot --network-backend litep2p` with a few
different peer configurations and there is a noticeable reduction in
networking CPU usage. For high load (`--out-peers 200`), networking CPU
usage goes down from ~110% to ~30% (80 pp) and for normal load
(`--out-peers 40`), the usage goes down from ~55% to ~18% (37 pp).

These should not be taken as final numbers because:

a) there are still some low-hanging optimization fruits, such as
enabling [receive window
auto-tuning](https://github.com/libp2p/rust-yamux/pull/176), integrating
`Peerset` more closely with `litep2p` or improving memory usage of the
WebSocket transport
b) fixing bugs/instabilities that incorrectly cause `litep2p` to do less
work will increase the networking CPU usage
c) verification in a more diverse set of tests/conditions is needed

Nevertheless, these numbers should give an early estimate for CPU usage
of the new networking backend.

This PR consists of three separate changes:
* introduce a generic `PeerId` (wrapper around `Multihash`) so that we
don't have use `NetworkService::PeerId` in every part of the code that
uses a `PeerId`
* introduce `NetworkBackend` trait, implement it for the libp2p network
stack and make Polkadot SDK generic over `NetworkBackend`
  * implement `NetworkBackend` for litep2p

The new library should be considered experimental which is why
`rust-libp2p` will remain as the default option for the time being. This
PR currently depends on the master branch of `litep2p` but I'll cut a
new release for the library once all review comments have been
addresses.

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Dmitry Markin <dmitry@markin.tech>
Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>
Co-authored-by: Alexandru Vasile <alexandru.vasile@parity.io>
2024-04-08 16:44:13 +00:00

94 lines
3.9 KiB
TOML

[package]
name = "polkadot-subsystem-bench"
description = "Subsystem performance benchmark client"
version = "1.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
readme = "README.md"
publish = false
[lib]
name = "polkadot_subsystem_bench"
path = "src/lib/lib.rs"
[[bin]]
name = "subsystem-bench"
path = "src/cli/subsystem-bench.rs"
# Prevent rustdoc error. Already documented from top-level Cargo.toml.
doc = false
[dependencies]
polkadot-node-subsystem = { path = "../subsystem" }
polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-node-subsystem-types = { path = "../subsystem-types" }
polkadot-node-primitives = { path = "../primitives" }
polkadot-primitives = { path = "../../primitives" }
polkadot-node-network-protocol = { path = "../network/protocol" }
polkadot-availability-recovery = { path = "../network/availability-recovery", features = ["subsystem-benchmarks"] }
polkadot-availability-distribution = { path = "../network/availability-distribution" }
polkadot-node-core-av-store = { path = "../core/av-store" }
polkadot-node-core-chain-api = { path = "../core/chain-api" }
polkadot-availability-bitfield-distribution = { path = "../network/bitfield-distribution" }
color-eyre = { version = "0.6.1", default-features = false }
polkadot-overseer = { path = "../overseer" }
colored = "2.0.4"
assert_matches = "1.5"
async-trait = "0.1.79"
sp-keystore = { path = "../../../substrate/primitives/keystore" }
sc-keystore = { path = "../../../substrate/client/keystore" }
sp-core = { path = "../../../substrate/primitives/core" }
clap = { version = "4.5.3", features = ["derive"] }
futures = "0.3.30"
futures-timer = "3.0.2"
bincode = "1.3.3"
sha1 = "0.10.6"
hex = "0.4.3"
gum = { package = "tracing-gum", path = "../gum" }
polkadot-erasure-coding = { package = "polkadot-erasure-coding", path = "../../erasure-coding" }
log = { workspace = true, default-features = true }
env_logger = "0.11"
rand = "0.8.5"
# `rand` only supports uniform distribution, we need normal distribution for latency.
rand_distr = "0.4.3"
bitvec = "1.0.1"
kvdb-memorydb = "0.13.0"
parity-scale-codec = { version = "3.6.1", features = ["derive", "std"] }
tokio = { version = "1.24.2", features = ["parking_lot", "rt-multi-thread"] }
clap-num = "1.0.2"
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
sp-keyring = { path = "../../../substrate/primitives/keyring" }
sp-application-crypto = { path = "../../../substrate/primitives/application-crypto" }
sc-network = { path = "../../../substrate/client/network" }
sc-network-types = { path = "../../../substrate/client/network/types" }
sc-service = { path = "../../../substrate/client/service" }
sp-consensus = { path = "../../../substrate/primitives/consensus/common" }
polkadot-node-metrics = { path = "../metrics" }
itertools = "0.11.0"
polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" }
prometheus_endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" }
prometheus = { version = "0.13.0", default-features = false }
serde = { workspace = true, default-features = true }
serde_yaml = { workspace = true }
serde_json = { workspace = true }
polkadot-node-core-approval-voting = { path = "../core/approval-voting" }
polkadot-approval-distribution = { path = "../network/approval-distribution" }
sp-consensus-babe = { path = "../../../substrate/primitives/consensus/babe" }
sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false }
sp-timestamp = { path = "../../../substrate/primitives/timestamp" }
schnorrkel = { version = "0.11.4", default-features = false }
# rand_core should match schnorrkel
rand_core = "0.6.2"
rand_chacha = { version = "0.3.1" }
paste = "1.0.14"
orchestra = { version = "0.3.5", default-features = false, features = ["futures_channel"] }
pyroscope = "0.5.7"
pyroscope_pprofrs = "0.2.7"
[features]
default = []