Hey! So I cloned your repo and been doing some basic testing, curious, what the bottleneck is here, both servers are running in debug mode, personally I can’t ZIO to work on my laptop, but dusty works fine? Is llhttp the bottleneck here, cause the metrics seems to be extremely off, and I also have built my own custom event loop, which is single threaded?
Its a very simple wrk request just to see the event loops ability
wrk -t1 -c50 -d10s http://127.0.0.1:8080/ping
dusty results
Running 10s test @ http://127.0.0.1:8080/ping
1 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 421.05us 100.35us 11.41ms 96.89%
Req/Sec 111.50k 2.28k 113.55k 96.04%
1120759 requests in 10.10s, 49.17MB read
Requests/sec: 110958.17
Transfer/sec: 4.87MB
other server results
Running 10s test @ http://127.0.0.1:8080/ping
1 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 185.82us 90.20us 2.57ms 89.17%
Req/Sec 167.04k 25.10k 188.65k 86.14%
1678688 requests in 10.10s, 158.49MB read
Requests/sec: 166170.75
Transfer/sec: 15.69MB
For dusty I’m just using the basic example setup but with the following handle root
fn handleRoot(ctx: *AppContext, req: *http.Request, res: *http.Response) !void {
_ = ctx;
_ = req;
res.body = "SUCCESS\n";
}
pub fn runServer(allocator: std.mem.Allocator, rt: *zio.Runtime) !void {
var ctx: AppContext = .{ .rt = rt };
const AppServer = http.Server(AppContext);
const config: http.ServerConfig = .{
.timeout = .{
.request = 60 * std.time.ms_per_s,
.keepalive = 300 * std.time.ms_per_s,
},
};
var server = AppServer.init(allocator, config, &ctx);
defer server.deinit();
// Register routes
server.router.get("/ping", handleRoot);
var signal = try zio.Signal.init(.interrupt);
defer signal.deinit();
const addr = try zio.net.IpAddress.parseIp("127.0.0.1", 8080);
var task = try rt.spawn(AppServer.listen, .{ &server, rt, addr }, .{});
defer task.cancel(rt);
while (true) {
const result = try zio.select(rt, .{ .task = &task, .signal = &signal });
switch (result) {
.task => |r| {
return r;
},
.signal => {
server.stop();
},
}
}
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var rt = try zio.Runtime.init(allocator, .{});
defer rt.deinit();
try rt.runUntilComplete(runServer, .{ allocator, rt }, .{});
}
Love the work so far, but not sure if there is some configuration or something I need to do to get Dusty up in performance, or if you are mainly working on ergonomics, but I assume zio is great, since you mentioned it outperfs go and tokio.
Thanks for all the help!