-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The reason for the performance difference is likely the use of sendfile in the Rust implementation by way of std::io::copy when you do
std::io::copy(&mut body.reader(), &mut stdout)?;On Linux and Android that calls sys::kernel_copy::copy_spec which has sendfile optimizations. In the zig implementation you do,
const body = request.reader().readAllAlloc(allocator, 8192) catch unreachable;
defer allocator.free(body);
const stdout = std.io.getStdOut().writer();
try stdout.print("{} {s}\n", .{i, body});
When you should probably be doing something like std.os.sendfile or something like that. I don't write Zig but the patch for sendfile optimizations landed there. Zig has had these optimization since 2020
The lack of sendfile means you made an additional double-copy, moving all the data from kernel space to user space and back.
Good luck!
Follow up questions from me
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request