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

refactor(bindings/bench): make harness own IO #4847

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jmayclin
Copy link
Contributor

Description of changes:

The goal of this PR is to reduce unnecessary abstraction.

Ideally the S2NConnection and OpenSSLConnection structs would just alias the raw types from the corresponding libraries, like s2n_tls::connection::Connection. This refactor is a step in that direction.

Now the ConnPair owns that actual IO Stream, and connections are just handed references (views) to it. Note that I simply used reference counters Rc rather than trying to thread lifetimes through everything.

Testing:

All existing tests should continue to pass.

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

@jmayclin jmayclin marked this pull request as ready for review October 16, 2024 01:08
@github-actions github-actions bot added the s2n-core team label Oct 16, 2024
Copy link
Contributor

@maddeleine maddeleine left a comment

Choose a reason for hiding this comment

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

Have you actually checked that the benchmarks still run with these changes?

@@ -0,0 +1,64 @@
use std::{cell::RefCell, collections::VecDeque, io::ErrorKind, pin::Pin, rc::Rc};
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright notice?

// This struct is used by Openssl and Rustls which both rely on a "stream" abstraction
// which implements read and write. This is not used by s2n-tls, which relies on
// lower level callbacks.
pub struct ViewIO {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I insane, how is the ViewIO struct different than the TestPairIO struct?

@@ -325,93 +311,6 @@ where

Ok(())
}

/// Shrink buffers owned by the connections
pub fn shrink_connection_buffers(&mut self) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we have these shrink functions? How are we able to just delete them without having issues?

Comment on lines +111 to 114
conn_pair = TlsConnPair::<T, T>::from_configs(
CryptoConfig::default(),
HandshakeType::default(),
buffers.pop().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this work? Doesn't from_configs accept a client and server config?

Comment on lines -364 to -367
// prevent (potentially slow) resizing of buffers for small data transfers,
// like with handshake
recv.borrow_mut().reserve(10000);
send.borrow_mut().reserve(10000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this important?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants