From 6a19e80a3a96cf08ab4063e2fcaf58ff3a8e05c9 Mon Sep 17 00:00:00 2001 From: godzie44 Date: Thu, 1 May 2025 12:42:04 +0300 Subject: [PATCH 1/2] bench: update echo-server benches --- example/echo-server/bench.sh | 4 ++-- example/echo-server/benchmark.md | 12 ++++++------ example/echo-server/uring.go | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/example/echo-server/bench.sh b/example/echo-server/bench.sh index 0ddb059..983d9fd 100755 --- a/example/echo-server/bench.sh +++ b/example/echo-server/bench.sh @@ -17,8 +17,8 @@ do sudo cset shield --shield --pid $SRV_PID sleep 1s - OUT=cargo run -q --manifest-path $2 --release -- --address "127.0.0.1:8080" --number $conn_cnt --duration 30 --length $msg_len - RPS=$(echo "${OUT}" | sed -n '/^Speed/ p' | sed -r 's|^([^.]+).*$|\1|; s|^[^0-9]*([0-9]+).*$|\1 |') + OUT=tcp-echo-benchmark --address "127.0.0.1:8080" --number $conn_cnt --duration 30 --length $msg_len + RPS=$(echo "${OUT}" | sed -n 's/Throughput: \([0-9]*\) request\/sec.*/\1/p') RPS_SUM=$((RPS_SUM + RPS)) echo "attempt: $attempt, rps: $RPS " diff --git a/example/echo-server/benchmark.md b/example/echo-server/benchmark.md index 517497b..68cc36d 100644 --- a/example/echo-server/benchmark.md +++ b/example/echo-server/benchmark.md @@ -15,18 +15,18 @@ __Linux 5.7 or higher__ * Echo server is assigned a dedicated CPU with cset ## benchmark tool -* Rust echo bench: https://github.com/haraldh/rust_echo_bench -* `cargo run --release -- --address "localhost:8080" --number {number of clients} --duration 30 --length {msg size}` +* Rust echo bench: https://crates.io/crates/tcp-echo-benchmark +* `tcp-echo-benchmark --address "localhost:8080" --number {number of clients} --duration 30 --length {msg size}` * 5 runs for each combination of 128 and 1024 bytes message size with 100, 500 and 1000 clients * [bench.sh](#benchmark script) script using for benchmarking # Results -| | c: 100 bytes: 128 | c: 50 bytes: 1024| c: 500 bytes: 128 | c: 500 bytes: 1024| c: 1000 bytes: 128 | c: 1000 bytes: 1024| +| | c: 100 bytes: 128 | c: 100 bytes: 1024| c: 500 bytes: 128 | c: 500 bytes: 1024| c: 1000 bytes: 128 | c: 1000 bytes: 1024| |-------------------------------|-------------------|------------------|-------------------|-------------------|--------------------|--------------------| -| epoll echo-server | 160869 | 154727 | 153380 | 145018 | 149071 | 143961 | -| io_uring echo-server | 232376 | 223385 | 220271 | 212599 | 202515 | 187121 | -| io_uring-echo-server (C lang) | 242813 | 233604 | 220429 | 218261 | 205329 | 183582 | +| epoll echo-server | 267055 | 259730 | 276911 | 264069 | 274568 | 258904 | +| io_uring echo-server | 355931 | 310814 | 364609 | 364675 | 363552 | 303197 | +| io_uring-echo-server (C lang) | 379458 | 361902 | 386219 | 367076 | 382633 | 284460 | ### benchmark script diff --git a/example/echo-server/uring.go b/example/echo-server/uring.go index cef8c50..7994714 100644 --- a/example/echo-server/uring.go +++ b/example/echo-server/uring.go @@ -7,10 +7,11 @@ import ( "errors" "flag" "fmt" - "github.com/godzie44/go-uring/uring" "log" "strconv" "syscall" + + "github.com/godzie44/go-uring/uring" ) const MaxConns = 4096 From 94926ad98b39b54099e4d92c106ef845dcf68454 Mon Sep 17 00:00:00 2001 From: godzie44 Date: Thu, 1 May 2025 12:42:23 +0300 Subject: [PATCH 2/2] ci: fix golangci-lint --- .github/workflows/lint.yml | 3 --- example/echo-server/{ => epoll}/epoll.go | 4 +++- example/echo-server/{ => uring}/uring.go | 4 +++- 3 files changed, 6 insertions(+), 5 deletions(-) rename example/echo-server/{ => epoll}/epoll.go (96%) rename example/echo-server/{ => uring}/uring.go (99%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 035a279..206d8c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,9 +1,6 @@ name: golangci-lint on: push: - branches: - - master - - main pull_request: jobs: golangci: diff --git a/example/echo-server/epoll.go b/example/echo-server/epoll/epoll.go similarity index 96% rename from example/echo-server/epoll.go rename to example/echo-server/epoll/epoll.go index abed74f..f11083e 100644 --- a/example/echo-server/epoll.go +++ b/example/echo-server/epoll/epoll.go @@ -1,3 +1,5 @@ +//nolint + package main import ( @@ -58,7 +60,7 @@ func main() { if events[i].Fd == int32(sockFd) { connFd, _, err := unix.Accept4(sockFd, unix.SOCK_NONBLOCK) if err != nil { - log.Printf("Error accepting connection:", err) + log.Printf("Error accepting connection: %s", err) continue } diff --git a/example/echo-server/uring.go b/example/echo-server/uring/uring.go similarity index 99% rename from example/echo-server/uring.go rename to example/echo-server/uring/uring.go index 7994714..e3563d4 100644 --- a/example/echo-server/uring.go +++ b/example/echo-server/uring/uring.go @@ -1,3 +1,5 @@ +//nolint + //go:build linux // +build linux @@ -63,7 +65,7 @@ func makeBuffers() [][]byte { var buffs = makeBuffers() -func main() { +func main() { //nolint flag.Parse() port, _ := strconv.Atoi(flag.Arg(0))