Skip to content

webrtc: track number of bytes sent / received by all substreams#3162

Closed
melekes wants to merge 10 commits into
libp2p:3157-bandwidth-loggingfrom
melekes:3157-bandwidth-logging
Closed

webrtc: track number of bytes sent / received by all substreams#3162
melekes wants to merge 10 commits into
libp2p:3157-bandwidth-loggingfrom
melekes:3157-bandwidth-logging

Conversation

@melekes
Copy link
Copy Markdown
Contributor

@melekes melekes commented Nov 23, 2022

Continuation of #3161

Comment thread transports/webrtc/src/tokio/connection.rs Outdated
@melekes melekes marked this pull request as ready for review November 24, 2022 03:33
@melekes melekes marked this pull request as draft November 24, 2022 03:49
@melekes melekes marked this pull request as ready for review November 24, 2022 04:53
@melekes
Copy link
Copy Markdown
Contributor Author

melekes commented Nov 24, 2022

Okay, now measurement is more accurate, but I'm slightly worried about added complexity comparing to just logging bytes without webrtc headers & DTLS (49da84f).

@tomaka do you have an opinion here?

Comment thread src/bandwidth.rs Outdated
@tomaka
Copy link
Copy Markdown
Member

tomaka commented Nov 24, 2022

Just logging without the headers would have the advantage of being a generic solution, as it could be plugged on top of any StreamMuxer.
From the perspective of a user of libp2p I don't care either way.

}));
}

/// Fetches the current bandwidth (for all connections). Counters are reset after each call.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know this is not perfect from API design, but it's the trade-off. You can browse the commit history.

Comment thread src/bandwidth.rs
}

// #[cfg(all(feature = "uds", feature = "async-std"))]
// impl WithBandwidthSinks for async_std::os::unix::net::UnixStream {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure what to do with transports who don't have their own connection type. is it okay to import async_std/tokio here? or I should reexport these types?

Transport,
};
use rw_stream_sink::RwStreamSink;
pub use rw_stream_sink::RwStreamSink;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is it okay to reexport to avoid importing rw_stream_sink in src/bandwidth.rs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd suggest make a type alias for the stream. That is why I did for TCP.

@thomaseizinger
Copy link
Copy Markdown
Contributor

Just logging without the headers would have the advantage of being a generic solution, as it could be plugged on top of any StreamMuxer.
From the perspective of a user of libp2p I don't care either way.

Thanks for commenting! I thought I had read a comment from you somewhere that you'd prefer if we measured as far down the stack as possible.

I'd very much be in favor of a generic solution instead of what we have here at the moment. Ideally, maybe even segregated by protocol, e.g. /ipfs/ping/1.0.0 for example. That would need first-class support in libp2p-swarm though but I don't think that is necessarily a bad thing.

However, we can only do that if the trade-offs involved are acceptable for people.

Comment thread transports/webrtc/src/tokio/bandwidth.rs Outdated
Transport,
};
use rw_stream_sink::RwStreamSink;
pub use rw_stream_sink::RwStreamSink;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd suggest make a type alias for the stream. That is why I did for TCP.

@melekes
Copy link
Copy Markdown
Contributor Author

melekes commented Nov 29, 2022

Thanks for commenting! I thought I had read a comment from you somewhere that you'd prefer if we measured as far down the stack as possible.

I was under the same impression as well.

I'd very much be in favor of a generic solution instead of what we have here at the moment. Ideally, maybe even segregated by protocol, e.g. /ipfs/ping/1.0.0 for example. That would need first-class support in libp2p-swarm though but I don't think that is necessarily a bad thing.

Same. @mxinden proposed counting only the goodput here: #3157 (comment)

@melekes
Copy link
Copy Markdown
Contributor Author

melekes commented Nov 29, 2022

Let's continue the discussion here

@melekes
Copy link
Copy Markdown
Contributor Author

melekes commented Nov 30, 2022

Replaced by #3180

@melekes melekes closed this Nov 30, 2022
@melekes melekes deleted the 3157-bandwidth-logging branch November 30, 2022 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants