-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
chore: remove tokio01::codec #3095
Conversation
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
Can you add your name, for all of the done files in here, to #2945. |
Added. It's can be hard to make changes while this not merged, but I think changing shutdown to future:0.3 should not be blocked and require a lot of rebases in future. I'll address all comments here tomorrow, so hope that we will able merge this quickly. |
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
@@ -225,13 +241,20 @@ impl Sink for TcpSink { | |||
emit!(TcpEventSent { | |||
byte_size: line.len() | |||
}); | |||
let line = Bytes::copy_from_slice(&line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a conversion between two bytes
crates in unfortunate. The extra copies are probably not that big of a hit to the performance, and it's temporary, so I guess it's ok. Just pointing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. The bad part of such slow update that in the future we will need to find and rid all such conversions. Also new bytes
have extra copying on converting between Bytes <=> BytesMut 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, yet it seems kind of odd that Bytes
were convertible to BytesMut
before in the first place. The API seems to have been incorrect, thus we're probably using it incorrectly... We probably should do an audit of the code as part of old bytes
removal - I bet there are a lot of places where we can avoid copying where we could just switch to Bytes
to BytesMut
(or do sth similar).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interesting thing, will clippy
catch extra operations with Bytes or not. I already started improving bytes
from BytesMut => Bytes through freeze, but this pretty hard for my current Rust level. tokio-rs/bytes#418
Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Kirill Fomichev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot here, but it generally looks reasonable to me. Left a few notes on things that may or may not be important, but shouldn't block. If CI is passing, then I'm good to merge.
In the future, it would be helpful to break down changes like this into a couple of pull requests. Smaller diff and more limited scope makes them quicker to review, quicker to merge, fewer conflicts, etc.
} | ||
|
||
fn unix_healthcheck(path: PathBuf) -> Healthcheck { | ||
// Lazy to avoid immediately connecting | ||
let check = future::lazy(move || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reasoning for lazy
is still valid here unless you've verified that connect
doesn't bind to the port until polled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good note. I actually do not understand why new futures need lazy
function, because new futures not executed while not pulled, for example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=1903bb7388f8d2965ee127bf8db2675c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why new futures need lazy function,
I think it's because Rust can't yet pass bare async closures around, thus this future::lazy
.
Here: https://docs.rs/futures-util/0.3.5/src/futures_util/future/lazy.rs.html#34-38, it's very similar to poll!
macro: https://docs.rs/futures-util/0.3.5/src/futures_util/async_await/poll.rs.html#13-17
let socket = UdpSocket::bind(&addr).expect("failed to bind to udp listener socket"); | ||
|
||
async move { | ||
let socket = UdpSocket::bind(&addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above for lazy
and bind
.
@@ -39,41 +42,46 @@ pub fn udp( | |||
let out = out.sink_map_err(|e| error!("error sending event: {:?}", e)); | |||
|
|||
Box::new( | |||
future::lazy(move || { | |||
let socket = UdpSocket::bind(&address).expect("failed to bind to udp listener socket"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
let socket = UdpSocket::bind(&addr).expect("failed to bind to udp listener socket"); | ||
|
||
async move { | ||
let socket = UdpSocket::bind(&addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too 😄
* chore: remove tokio01::codec Signed-off-by: Kirill Fomichev <[email protected]> Signed-off-by: Jesse Szwedko <[email protected]>
* chore: remove tokio01::codec Signed-off-by: Kirill Fomichev <[email protected]> Signed-off-by: Brian Menges <[email protected]>
Ref. #2945 (comment)