-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Not fair to zig, need to use sendfile. #16
Comments
Sendfile is cool! however: it hadn't been implemented in std.http yet because it has some rather drastic constraints.
These constraints mean that this optimization simply doesn't apply in most cases (yes, I'm aware it does apply here), so it hasn't been a priority. If I were to guess the zig benchmark would gain more performance out of switching to a faster allocator (like Also, to answer your questions:
Unfortunately not, pump would need to have a special case for handling the combination of
Short answer: no |
Sendfile should work in a kernel with TLS using the kTLS optimization which should exist on all modern kernels. But the rest is true. Not sure how much an issue Chunked HTTP Encoding is, http2 drops it entirely. I still think any allocation is going to be an insurmountable problem for any micro benchmark like this against a sendfile optimization. And, it's not likely that this response would benefit from compression. But I agree at the point you're using deflate/brotli you generally lose sendfile. That may be one way to stop the optimization here if we don't want to benchmark sendfile -- force brotli on the response. It's a clever trick. My assumption is for this benchmark you either got |
As a last question @truemedian is it possible to use the internal |
It's possible, but bound to break at some point. |
The reason for the performance difference is likely the use of
sendfile
in the Rust implementation by way ofstd::io::copy
when you doOn Linux and Android that calls
sys::kernel_copy::copy_spec
which hassendfile
optimizations. In the zig implementation you do,When you should probably be doing something like
std.os.sendfile
or something like that. I don't write Zig but the patch forsendfile
optimizations landed there. Zig has had these optimization since 2020The 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
The text was updated successfully, but these errors were encountered: