1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
zap/wrk/measure.sh
Rene Schallner 49f5cd9342
perf-measures: re-introduce httpz
In the 0.12.0 branch, [httpz](https://github.com/karlseguin/http.zig)
was added to the perf measurements.

Apparently, somehow this got lost, which is a pity. httpz is
super-promising.

Given the perf benchmarks in [this
PR comment](https://github.com/antonputra/tutorials/pull/280#issuecomment-2362637299),
I would have expected httpz to be on par with or better than zap in our
`measure.sh` tests.

However, on my M3 max mac box, I get the following:

**ZAP**:

```
➜  zap git:(reintroduce_httpz_perf) ✗ ./wrk/measure.sh zig-zap
INFO: Listening on port 3000
Listening on 0.0.0.0:3000
INFO: Server is running 4 workers X 4 threads with facil.io 0.7.4 (kqueue)
* Detected capacity: 131056 open file limit
* Root pid: 73099
* Press ^C to stop

INFO: 73110 is running.
INFO: 73111 is running.
INFO: 73112 is running.
INFO: 73113 is running.
========================================================================
                          zig-zap
========================================================================
Running 10s test @ http://127.0.0.1:3000
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.31ms  533.41us  18.77ms   90.57%
    Req/Sec    76.67k     9.04k   86.46k    84.25%
  Latency Distribution
     50%    1.15ms
     75%    1.17ms
     90%    1.75ms
     99%    2.94ms
  3052064 requests in 10.02s, 462.80MB read
  Socket errors: connect 0, read 135, write 0, timeout 0
Requests/sec: 304601.19
Transfer/sec:     46.19MB
```

**httpz**:

```
➜  zap git:(reintroduce_httpz_perf) ✗ ./wrk/measure.sh httpz
========================================================================
                          httpz
========================================================================
Running 10s test @ http://127.0.0.1:3000
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.26ms  528.72us  18.84ms   84.61%
    Req/Sec    44.46k     7.35k   85.50k    88.00%
  Latency Distribution
     50%    2.35ms
     75%    2.39ms
     90%    2.43ms
     99%    3.26ms
  1768925 requests in 10.01s, 91.10MB read
  Socket errors: connect 0, read 230, write 0, timeout 0
Requests/sec: 176712.50
Transfer/sec:      9.10MB
```

Which looks way off. I must admit, I might have done a bad httpz
implementation.

Seeking help from @karlseguin. My motivation: route people away from zap
to alternatives like httpz or even zzz, as those are pure zig, and seem
to be of really good performance. I want a world in which we don't have
to resort to C frameworks to do good, zig-worthy servers 😄 to come
true.
2024-09-20 15:05:13 +02:00

113 lines
2.6 KiB
Bash
Executable file

#! /usr/bin/env bash
THREADS=4
CONNECTIONS=400
DURATION_SECONDS=10
SUBJECT=$1
TSK_SRV="taskset -c 0,1,2,3"
TSK_LOAD="taskset -c 4,5,6,7"
if [ $(echo $(uname)) = "Darwin" ] ; then
TSK_SRV=""
TSK_LOAD=""
fi
if [ "$SUBJECT" = "" ] ; then
echo "usage: $0 subject # subject: zig or go"
exit 1
fi
if [ "$SUBJECT" = "zig-zap" ] ; then
zig build -Doptimize=ReleaseFast wrk > /dev/null
$TSK_SRV ./zig-out/bin/wrk &
PID=$!
URL=http://127.0.0.1:3000
fi
if [ "$SUBJECT" = "httpz" ] ; then
cd wrk/httpz
zig build -Doptimize=ReleaseFast > /dev/null
$TSK_SRV ./zig-out/bin/httpz &
PID=$!
URL=http://127.0.0.1:3000
fi
if [ "$SUBJECT" = "zigstd" ] ; then
zig build -Doptimize=ReleaseFast wrk_zigstd > /dev/null
$TSK_SRV ./zig-out/bin/wrk_zigstd &
PID=$!
URL=http://127.0.0.1:3000
fi
if [ "$SUBJECT" = "go" ] ; then
cd wrk/go && go build main.go
$TSK_SRV ./main &
PID=$!
URL=http://127.0.0.1:8090/hello
fi
if [ "$SUBJECT" = "python" ] ; then
$TSK_SRV python wrk/python/main.py &
PID=$!
URL=http://127.0.0.1:8080
fi
if [ "$SUBJECT" = "python-sanic" ] ; then
$TSK_SRV python wrk/sanic/sanic-app.py &
PID=$!
URL=http://127.0.0.1:8000
fi
if [ "$SUBJECT" = "rust-bythebook" ] ; then
cd wrk/rust/bythebook && cargo build --release
$TSK_SRV ./target/release/hello &
PID=$!
URL=http://127.0.0.1:7878
fi
if [ "$SUBJECT" = "rust-bythebook-improved" ] ; then
cd wrk/rust/bythebook-improved && cargo build --release
$TSK_SRV ./target/release/hello &
PID=$!
URL=http://127.0.0.1:7878
fi
if [ "$SUBJECT" = "rust-clean" ] ; then
cd wrk/rust/clean && cargo build --release
$TSK_SRV ./target/release/hello &
PID=$!
URL=http://127.0.0.1:7878
fi
if [ "$SUBJECT" = "rust-axum" ] ; then
cd wrk/axum/hello-axum && cargo build --release
$TSK_SRV ./target/release/hello-axum &
PID=$!
URL=http://127.0.0.1:3000
fi
if [ "$SUBJECT" = "csharp" ] ; then
cd wrk/csharp && dotnet publish csharp.csproj -o ./out
$TSK_SRV ./out/csharp --urls "http://127.0.0.1:5026" &
PID=$!
URL=http://127.0.0.1:5026
fi
if [ "$SUBJECT" = "cpp-beast" ] ; then
cd wrk/cpp && zig build -Doptimize=ReleaseFast
$TSK_SRV ./zig-out/bin/cpp-beast 127.0.0.1 8070 . &
PID=$!
URL=http://127.0.0.1:8070
fi
sleep 1
echo "========================================================================"
echo " $SUBJECT"
echo "========================================================================"
$TSK_LOAD wrk -c $CONNECTIONS -t $THREADS -d $DURATION_SECONDS --latency $URL
kill $PID