Skip to content

Commit

Permalink
First version of performance measurement rig
Browse files Browse the repository at this point in the history
Runs iperf3 via wireguard-go, main branch of NepTUN and the current
branch between two docker containers. The results are printed in the
job log. Probably we want to add some configurability to those scripts
but it is better to do it as we go, when we actually know what we need.
  • Loading branch information
jjanowsk committed Dec 5, 2024
1 parent db16cad commit 75fb893
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[target.'cfg(unix)']
runner = 'sudo -E'
[alias]
xtask = "run --package xtask --"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
)
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: CI Trigger
run: echo "Triggering CI"
Expand All @@ -27,7 +27,7 @@ jobs:
needs:
- linters
- tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Collect statuses from all jobs
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ permissions: {}

jobs:
rustfmt:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # v1.0.3
Expand All @@ -16,9 +16,9 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
packages: ""
- os: macos-12
- os: macos-14
packages: ""
- os: windows-2022
packages: "-p neptun"
Expand All @@ -33,9 +33,9 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
packages: ""
- os: macos-12
- os: macos-14
packages: ""
- os: windows-2022
packages: -p neptun
Expand All @@ -60,7 +60,7 @@ jobs:
args: '--workspace --locked --output human --backend depinfo'

deny:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: EmbarkStudios/cargo-deny-action@8371184bd11e21dcf8ac82ebf8c9c9f74ebf7268 # v2.0.1
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
packages: ""
- os: macos-12
- os: macos-14
packages: ""
- os: windows-2022
packages: -p neptun
Expand All @@ -24,19 +24,28 @@ jobs:
integration-tests:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
os: [ ubuntu-24.04, macos-14 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
- run: cargo test -- --ignored
- run: CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test -- --ignored

crypto-bench:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ ubuntu-24.04, macos-14, windows-2022 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
- run: cargo bench -p neptun --no-run

performance-tests:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- run: docker build -t neptun-runner:0.0.1 .
- run: cargo xtask perf --base LLT-5809-socket-reader
49 changes: 49 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["neptun", "neptun-cli"]
members = ["neptun", "neptun-cli", "xtask"]

[profile.release]
lto = true # Enable full link-time optimization.
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM debian:bookworm-slim
RUN apt-get update && apt-get install --no-install-recommends -y \
iperf3 \
iproute2 \
iputils-ping \
net-tools \
wireguard-go \
wireguard-tools \
&& rm -rf /var/lib/apt/lists/*
2 changes: 1 addition & 1 deletion neptun-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn main() {
use_connected_socket: !matches.get_flag("disable-connected-udp"),
#[cfg(target_os = "linux")]
use_multi_queue: !matches.get_flag("disable-multi-queue"),
open_uapi_socket: false,
open_uapi_socket: true,
protect: Arc::new(neptun::device::MakeExternalNeptunNoop),
firewall_process_inbound_callback: None,
firewall_process_outbound_callback: None,
Expand Down
12 changes: 12 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "xtask"
license = "BSD-3-Clause"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0"
clap = { version = "4.5", features = ["derive"] }
xshell = "0.2.7"
45 changes: 45 additions & 0 deletions xtask/perf/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3.2'

services:
left:
hostname: left
container_name: left
image: neptun-runner:0.0.1
entrypoint: /neptun/config/left.sh
privileged: true
depends_on:
right:
condition: service_healthy
networks:
default:
ipv4_address: 176.0.0.2
volumes:
- ../../target/release:/neptun/current
- ../../base/target/release:/neptun/base
- .:/neptun/config

right:
hostname: right
container_name: right
image: neptun-runner:0.0.1
entrypoint: /neptun/config/right.sh
privileged: true
healthcheck:
test: ["CMD-SHELL", "cat /.iperf_ready"]
interval: 1s
start_interval: 1s
start_period: 60s
networks:
default:
ipv4_address: 176.0.0.3
volumes:
- ../../target/release:/neptun/current
- ../../base/target/release:/neptun/base
- .:/neptun/config

networks:
default:
driver: bridge
ipam:
config:
- subnet: 176.0.0.0/24
47 changes: 47 additions & 0 deletions xtask/perf/left.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

wireguard-go wg0
wg set wg0 \
listen-port 51820 \
private-key <(echo AH7jKt6M0RS21MkRG+URrfgmwvJqdhVvqtKeF4WR+E8=) \
peer mqrc8+LD+6zvMeCtyCcIBPEYuXT74lq1Hros0Np8ZgA= \
allowed-ips 10.0.0.2/32 \
endpoint 176.0.0.3:51820
ip address add dev wg0 10.0.0.1/24
ip link set up dev wg0

/neptun/base/neptun-cli --disable-drop-privileges wg1
wg set wg1 \
listen-port 51821 \
private-key <(echo sKZoT3qgxDm1bWny+1ttoi00qS2KXvo1L4Zb265wr3c=) \
peer CMWokCGH+YPN7CL2C2aAkDlnhw1blH0tKPOnEOgzrxM= \
allowed-ips 10.0.1.2/32 \
endpoint 176.0.0.3:51821
ip address add dev wg1 10.0.1.1/24
ip link set up dev wg1

/neptun/current/neptun-cli --disable-drop-privileges wg2
wg set wg2 \
listen-port 51822 \
private-key <(echo 0Fn5JWI1QGDiaVYLDBSLklIEBUujfpX1oH/UGI2D62k=) \
peer fqrU1Wk8nuyy6phf8IUDwcKK1ElslFYDyteANr2hlgM= \
allowed-ips 10.0.2.2/32 \
endpoint 176.0.0.3:51822
ip address add dev wg2 10.0.2.1/24
ip link set up dev wg2

echo
echo "Raw network:"
iperf3 -i 10 -t 10 --bidir -c 176.0.0.3

echo
echo "Wireguard-go:"
iperf3 -i 60 -t 120 --bidir -c 10.0.0.2

echo
echo "Base NepTUN:"
iperf3 -i 60 -t 120 --bidir -c 10.0.1.2

echo
echo "Current NepTUN:"
iperf3 -i 60 -t 120 --bidir -c 10.0.2.2
35 changes: 35 additions & 0 deletions xtask/perf/right.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

wireguard-go wg0
wg set wg0 \
listen-port 51820 \
private-key <(echo MLBFYI9O69v8WdVodp4YucqnvW+onpD/R5kF/GE18F8=) \
peer 7gr2QZyPpaIdlsPcZcQozgpjDdCkefZtxz12Dmpj/3Y= \
allowed-ips 10.0.0.1/32 \
endpoint 176.0.0.2:51820
ip address add dev wg0 10.0.0.2/24
ip link set up dev wg0

/neptun/base/neptun-cli --disable-drop-privileges wg1
wg set wg1 \
listen-port 51821 \
private-key <(echo WAoFbPJ6QaXXltwLqBADFkMG6qLZuivSlkIUv2Sc3lY=) \
peer HcDZRTIcI3Yok4XTwhAScKoNkb9MIZ2wyjS1oQvZnic= \
allowed-ips 10.0.1.1/32 \
endpoint 176.0.0.2:51821
ip address add dev wg1 10.0.1.2/24
ip link set up dev wg1

/neptun/current/neptun-cli --disable-drop-privileges wg2
wg set wg2 \
listen-port 51822 \
private-key <(echo eNOePaXKpyN9IjNEDe1a4CzBAwdbLupbF5wfdCUjS18=) \
peer zj6KZHkVw3ILScBGgUaYfuRkwhK6GgrIHmzfd4MPx1k= \
allowed-ips 10.0.2.1/32 \
endpoint 176.0.0.2:51822
ip address add dev wg2 10.0.2.2/24
ip link set up dev wg2

iperf3 -s > /dev/null &
touch /.iperf_ready
sleep infinity
15 changes: 15 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mod perf;

use clap::Parser;

#[derive(Parser, Debug)]
enum Cmd {
/// Run performance benchmark
Perf(perf::Cmd),
}

fn main() {
match Cmd::parse() {
Cmd::Perf(perf) => perf.run(),
}
}
Loading

0 comments on commit 75fb893

Please sign in to comment.