-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf-measures: re-introduce httpz #132
base: master
Are you sure you want to change the base?
Conversation
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](antonputra/tutorials#280 (comment)), 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.
BTW: I am aware that taking perf measures on a mac is not what I usually do. I just don't have access to that Linux box ATM. |
Super interesting! im getting similar httpz numbers on both M2 pro and Ryzen 5/linux but nowhere near 300 for zap - its more ballpark with the others. Impressive you are making me want to get an M3 max ! |
It is weird how different my results are. On an m2:
On an E3-1275 v6
For a "hello world" example, the main thing you can do is tweak the worker count and thread pool size. But if you're running var server = try httpz.Server(void).init(allocator, .{
.port = 3000,
.workers = .{.count = 2},
.thread_pool = .{.count = 6},
}, {}); |
I'm starting to suspect/fear that httpz has some scaling issues. I tested it on a 32 vcpu cloud instance, and couldn't get it to scale linearly (or close to) with # of threads. Although, for the life of me, I can't figure out where the bottleneck is. Profiling shows |
Thanks for sharing! Interesting to see the M2 pro numbers! |
[...] Awesome! Thanks for trying it with your configurations! The httpz Linux Transfer/sec readings would have been interesting, got cut off, but nvm. Looking at the differences on a Linux machine, httpz and zap don't seem that far off. Those are the only numbers that really matter IMHO because if you are serious about a server, you don't run it on a Mac - might be a hot take IDK.
Yeah, you have to be careful not to allocate more cores than you have - and cores are not created equal, esp. on new Macs. |
Very interesting! I have no clue wrt httpz either. Do you mean Hypotheticals that come to mind: ... wait. Actually, as food for thought, here are some ideas from ChatGPT :-)
Potential Solutions:
Sorry, it's a bit verbose, but I find it did a great job anyway :-) |
In the 0.12.0 branch, httpz 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, 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:
httpz:
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.