-
Notifications
You must be signed in to change notification settings - Fork 228
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
Shouldn't socket recv() promise in its doc allows a nicer API #501
Comments
You can use the As for the |
thanks for your reply. I should have, but forgot to clarify that, what I needed is Currently I'm using |
For |
I guess it was probably a tough decision for you the maintainers, but I was curious how much performance gain of the version with uninitialized buffer. Among all It's probably impossible to change it back, but I just felt it's not a worthy trade-off, i.e. disabling / crippling common use cases for (IMO) edge cases. |
I don't really have performance test ready, but here an example of using uninitialised memory for HTTP headers: 5225225/hyper@325b7e5 that saves ~5%.
It's not really the common case though. Most users of this library use advance features, where not initialising memory is considered the common case. |
5% seems to me really not worth changing a safe Rust code to unsafe Rust code, especially if in the grand scheme of a bigger system. |
5% is a lot actually. That's massive improvement. Especially for a 1 line change that is documented as supported by socket2. I think the best way forward is the read buf, which is still unstable. So closing in favour of #366. |
socket2/src/socket.rs
Lines 409 to 414 in c93cdcc
A friendly question: because of the above promise, is it true that this API could change its signature to accept
buf: &mut [u8]
? That will be so much helpful! (The current API is useless for many code bases whereunsafe
is not allowed / or strongly discouraged).(I noticed open issues like #366 , but it seems being there more than 1 year, when will it happen?) I'm a user of this crate and I think this current signature is really unnecessary hurdle for its users.
The text was updated successfully, but these errors were encountered: