From b51d7c832cf551f0ad5e86d6f596f97c758ec363 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Fri, 23 Dec 2022 11:37:02 +0100 Subject: [PATCH] Add 'outbound only' parameter --- pubsub/nim/main.nim | 5 ++++- pubsub/nim/manifest.toml | 1 + pubsub/nim/plotter.nim | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pubsub/nim/main.nim b/pubsub/nim/main.nim index 66a0a18..e7315f8 100644 --- a/pubsub/nim/main.nim +++ b/pubsub/nim/main.nim @@ -32,6 +32,7 @@ testground(client): .withRng(rng) #.withYamux() .withMplex() + .withMaxConnections(10000) .withTcpTransport(flags = {ServerFlags.TcpNoDelay}) #.withPlainText() .withNoise() @@ -97,6 +98,8 @@ testground(client): while peersInfo.len < client.testInstanceCount: peersInfo.add(await peersTopic.popFirst()) + peersInfo = peersInfo[client.param(int, "outbound_only") .. ^1] + rng.shuffle(peersInfo) let connectTo = client.param(int, "connection_count") @@ -109,7 +112,7 @@ testground(client): peerId = PeerId.init(peerInfo.id).tryGet() addrs = peerInfo.addrs.mapIt(MultiAddress.init(it).tryGet()) try: - await switch.connect(peerId, addrs) + await switch.connect(peerId, addrs).wait(5.seconds) connected.inc() except CatchableError as exc: echo "Failed to dial", exc.msg diff --git a/pubsub/nim/manifest.toml b/pubsub/nim/manifest.toml index 1b76e98..3ca8ed1 100644 --- a/pubsub/nim/manifest.toml +++ b/pubsub/nim/manifest.toml @@ -22,3 +22,4 @@ instances = { min = 2, max = 100000, default = 20 } message_count = { type = "int", desc = "number of messages to send per publisher", unit = "msg", default = 20 } warmup_messages = { type = "int", desc = "empty messages to send before test", unit = "msg", default = 10 } max_message_delay = { type = "int", desc = "max delay between messages per publisher", unit = "ms", default = 500 } + outbound_only = { type = "int", desc = "number of nodes without incoming connections", unit = "nodes", default = 0 } diff --git a/pubsub/nim/plotter.nim b/pubsub/nim/plotter.nim index 1ce45a9..62b0c9b 100644 --- a/pubsub/nim/plotter.nim +++ b/pubsub/nim/plotter.nim @@ -1,3 +1,4 @@ +import os import strutils import ggplotnim @@ -36,10 +37,15 @@ let df = df.filter(f{`time` < maxTime - 3}).mutate(f{"scaled_amount" ~ `amount` * factor}) +echo "Average max latency: ", df["maxLatencies", int].mean +echo "Average received count: ", df["amount", int].mean +echo "Minimum received count: ", df["amount", int].min + let sa = secAxis(name = "Reception count", trans = f{1.0 / factor}) ggplot(df, aes("time", "maxLatencies")) + geom_line(aes("time", y = "scaled_amount", color = "Amount")) + ylim(0, maxLatency) + + ggtitle(paramStr(1)) + legendPosition(0.8, -0.2) + scale_y_continuous(name = "Latency (ms)", secAxis = sa) + geom_line(aes("time", y = "maxLatencies", color = "Max")) +