Skip to content
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

Merged
merged 33 commits into from
Jul 23, 2020
Merged

chore: remove tokio01::codec #3095

merged 33 commits into from
Jul 23, 2020

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Jul 17, 2020

fanatid added 9 commits July 17, 2020 11:06
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]>
@fanatid fanatid added the type: tech debt A code change that does not add user value. label Jul 17, 2020
@fanatid fanatid self-assigned this Jul 17, 2020
fanatid added 10 commits July 18, 2020 01:45
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]>
@fanatid fanatid marked this pull request as ready for review July 18, 2020 19:00
Signed-off-by: Kirill Fomichev <[email protected]>
Cargo.toml Outdated Show resolved Hide resolved
src/async_read.rs Outdated Show resolved Hide resolved
Signed-off-by: Kirill Fomichev <[email protected]>
@fanatid fanatid requested a review from ktff July 19, 2020 16:52
@fanatid fanatid added sink: socket Anything `socket` sink related sink: statsd Anything `statsd` sink related source: socket Anything `socket` source related source: syslog Anything `syslog` source related source: vector Anything `vector` source related labels Jul 19, 2020
@ktff
Copy link
Contributor

ktff commented Jul 19, 2020

Can you add your name, for all of the done files in here, to #2945.

@lukesteensen lukesteensen mentioned this pull request Jul 19, 2020
47 tasks
@fanatid
Copy link
Contributor Author

fanatid commented Jul 19, 2020

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.

src/sinks/statsd.rs Outdated Show resolved Hide resolved
src/sinks/util/tcp.rs Outdated Show resolved Hide resolved
@@ -225,13 +241,20 @@ impl Sink for TcpSink {
emit!(TcpEventSent {
byte_size: line.len()
});
let line = Bytes::copy_from_slice(&line);
Copy link
Contributor

@MOZGIII MOZGIII Jul 21, 2020

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.

Copy link
Contributor Author

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 😞

Copy link
Contributor

@MOZGIII MOZGIII Jul 21, 2020

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).

Copy link
Contributor Author

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

Copy link
Member

@lukesteensen lukesteensen left a 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 || {
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

@MOZGIII MOZGIII Jul 22, 2020

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

src/sinks/util/unix.rs Outdated Show resolved Hide resolved
src/sinks/util/tcp.rs Outdated Show resolved Hide resolved
src/sources/util/tcp.rs Outdated Show resolved Hide resolved
let socket = UdpSocket::bind(&addr).expect("failed to bind to udp listener socket");

async move {
let socket = UdpSocket::bind(&addr)
Copy link
Member

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");
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too 😄

@fanatid fanatid merged commit f0f58f1 into master Jul 23, 2020
@fanatid fanatid deleted the tokio01-codec-remove branch July 23, 2020 10:50
jszwedko pushed a commit that referenced this pull request Jul 24, 2020
* chore: remove tokio01::codec

Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Jesse Szwedko <[email protected]>
mengesb pushed a commit to jacobbraaten/vector that referenced this pull request Dec 9, 2020
* chore: remove tokio01::codec

Signed-off-by: Kirill Fomichev <[email protected]>
Signed-off-by: Brian Menges <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sink: socket Anything `socket` sink related sink: statsd Anything `statsd` sink related source: socket Anything `socket` source related source: syslog Anything `syslog` source related source: vector Anything `vector` source related type: tech debt A code change that does not add user value.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants