Skip to content

Commit

Permalink
Merge pull request #12 from AkihiroSuda/bench
Browse files Browse the repository at this point in the history
add iperf3 benchmark
  • Loading branch information
giuseppe committed Aug 1, 2018
2 parents c4e1bc5 + a81294d commit a28a856
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ RUN ./autogen.sh && ./configure && make -j $(nproc)

FROM build AS test
USER 0
RUN apt update && apt install -y git indent libtool iproute2 clang clang-tidy
RUN apt update && apt install -y git indent libtool iproute2 clang clang-tidy iputils-ping iperf3
USER 1000:1000
RUN make indent && test -z "$(git diff)"
RUN make lint
CMD ["bash", "-c", "make -j \"$(nproc)\" distcheck"]
CMD ["bash", "-c", "make -j \"$(nproc)\" distcheck && PATH=$(pwd):$PATH make benchmark"]
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ indent:
indent -linux -l120 -T ssize_t -T pid_t -T SLIRP $(slirp4netns_SOURCES)
$(RM) *.c~

.PHONY: generate-man lint lint-full indent
benchmark:
benchmarks/benchmark-iperf3.sh

.PHONY: generate-man lint lint-full indent benchmark
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ unshared$ ping 10.0.2.2
unshared$ curl https://example.com
```

## Benchmarks

### iperf3 (netns -> host)

Aug 1, 2018, on [RootlessKit](https://github.com/rootless-containers/rootlesskit) Travis: https://travis-ci.org/rootless-containers/rootlesskit/builds/410721610

* slirp4netns: 1.07 Gbits/sec
* VPNKit: 528 Mbits/sec
* vdeplug_slirp: 771 Mbits/sec

The latest revision of slirp4netns is regularly benchmarked (`make benchmark`) on Travis: https://travis-ci.org/rootless-containers/slirp4netns

## Acknowledgement

* The files under [`qemu`](./qemu) directory were forked from [QEMU](https://github.com/qemu/qemu/commit/c447afd5783b9237fa51b7a85777007d8d568bfc).
Expand Down
25 changes: 25 additions & 0 deletions benchmarks/benchmark-iperf3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -xeuo pipefail

. $(dirname $0)/../tests/common.sh

iperf3 -s > /dev/null &
iperf3_pid=$!

unshare -r -n sleep infinity &
child=$!

wait_for_network_namespace $child

slirp4netns -c $child tun11 &
slirp_pid=$!

wait_for_network_device $child tun11
wait_for_ping_connectivity $child 10.0.2.2

function cleanup {
kill -9 $iperf3_pid $child $slirp_pid
}
trap cleanup EXIT

nsenter --preserve-credentials -U -n --target=$child iperf3 -c 10.0.2.2 -t 60
12 changes: 12 additions & 0 deletions tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ function wait_process_exits {
let COUNTER=COUNTER+1
done
}

function wait_for_ping_connectivity {
COUNTER=0
while [ $COUNTER -lt 20 ]; do
if nsenter --preserve-credentials -U -n --target=$1 ping -c 1 -w 1 $2; then
break
else
sleep 0.5
fi
let COUNTER=COUNTER+1
done
}

0 comments on commit a28a856

Please sign in to comment.