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

Add rustls handshake to benchmarks #4063

Merged
merged 32 commits into from
Jun 21, 2023
Merged

Add rustls handshake to benchmarks #4063

merged 32 commits into from
Jun 21, 2023

Conversation

tinzh
Copy link
Contributor

@tinzh tinzh commented Jun 16, 2023

Description of changes:

Add Rustls to handshake benchmarking and refactor benchmark harness.

Testing:

This change doesn't change the source code for s2n-tls and only builds on top of it, so it shouldn't affect tests. There are added benchmark harness specific unit tests that test the refactored harness.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@tinzh tinzh marked this pull request as ready for review June 16, 2023 23:01
@tinzh tinzh changed the title Add rustls handshake Add rustls handshake to benchmarks Jun 16, 2023
@jmayclin jmayclin requested review from jmayclin and maddeleine June 16, 2023 23:03
bindings/rust/bench/benches/handshake.rs Outdated Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Outdated Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Outdated Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Show resolved Hide resolved
bindings/rust/bench/src/rustls.rs Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Outdated Show resolved Hide resolved
bindings/rust/bench/src/s2n_tls.rs Show resolved Hide resolved
@tinzh tinzh requested a review from jmayclin June 19, 2023 20:01
bindings/rust/bench/benches/handshake.rs Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Show resolved Hide resolved
bindings/rust/bench/src/harness.rs Show resolved Hide resolved
bindings/rust/bench/src/s2n_tls.rs Show resolved Hide resolved
bindings/rust/bench/src/s2n_tls.rs Outdated Show resolved Hide resolved
send: Rc<RefCell<VecDeque<u8>>>,
}

impl ConnectedBuffer {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of this struct? It seems like you've already initialized the IO buffers in the individual harnesses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For Rustls and OpenSSL, you need a trait object implementing Read + Write, where you read and write messages to the other connection. Having ConnectedBuffer in harness.rs and not rustls.rs is mainly because OpenSSL would also need this trait impl. The IO buffers are also only ever initialized once, and we create new references to the buffers with Rc::clone().

Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably not put this struct in this file, since it's just for benchmarking code. It would be better to put it in some sort of common.rs file that has shared code. If you don't want to do that you could just put this in the rustls.rs file for right now, since that's where it's being used.

Actually that probably goes for anything in this file, is there a reason why you defined the CipherSuites in this file too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I'm cheating because I have extra context, but this struct is common to multiple benchmarks (or will be once we merge in the Openssl benchmark). If we want to could break it out into a utilities module? For the time being I'm okay with it living in the same file.

I think the CipherSuites are in this file because we need some way of abstracting over the individual configuration for each implementation, because individual implementations are so different (e.g. s2n-tls is the only one with a concept of security policies)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the harness would also be common to the s2n-tls and rustls impls, wouldn't the harness trait also belong in common.rs? I guess I've been treating harness.rs as common.rs, but I feel like having both might be a little redundant because both harness.rs and common.rs would have shared code.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's more like, there seems to be a distinction between the harness trait that each library has to implement in order to benchmark, and the code necessary to setup each library to handshake. So in my mind it makes the most sense to have those be in separate files. But it doesn't sound like anyone else thinks this distinction is important so I'm cool with approving it.

@tinzh tinzh requested a review from maddeleine June 19, 2023 21:59
@tinzh tinzh self-assigned this Jun 19, 2023
send: Rc<RefCell<VecDeque<u8>>>,
}

impl ConnectedBuffer {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's more like, there seems to be a distinction between the harness trait that each library has to implement in order to benchmark, and the code necessary to setup each library to handshake. So in my mind it makes the most sense to have those be in separate files. But it doesn't sound like anyone else thinks this distinction is important so I'm cool with approving it.

@tinzh tinzh enabled auto-merge (squash) June 20, 2023 23:02
@tinzh tinzh merged commit b96117f into aws:main Jun 21, 2023
tinzh added a commit to tinzh/s2n-tls that referenced this pull request Jun 22, 2023
@tinzh tinzh deleted the add-rustls-handshake branch June 22, 2023 17:06
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