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

move sendable_plaintext from CommonState to ConnectionCommon #1591

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

japaric
Copy link
Contributor

@japaric japaric commented Nov 15, 2023

this is a refactor that follows up from #1583 and removes one of the 3 internal buffers in CommonState so that the UnbufferedConnection API does not inherit it.

breaking changes:

  • CommonState::set_buffer_limit was moved into ConnectionCommon. this is technically a breaking change but users of the set_buffer_limit API through ConnectionCommon and Connection won't notice the change. in fact, none of the existing examples / tests required changes due to this "breaking" change

this PR is best reviewed on a commit by commit basis (do skip the PR1583 commits)

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (371463d) 95.60% compared to head (3c24390) 95.59%.
Report is 1 commits behind head on main.

Files Patch % Lines
rustls/src/conn.rs 79.16% 5 Missing ⚠️
rustls/src/common_state.rs 97.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1591      +/-   ##
==========================================
- Coverage   95.60%   95.59%   -0.01%     
==========================================
  Files          79       79              
  Lines       16662    16704      +42     
==========================================
+ Hits        15930    15969      +39     
- Misses        732      735       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cpu
Copy link
Member

cpu commented Nov 27, 2023

this PR is best reviewed on a commit by commit basis (do skip the PR1583 commits)

It's a bit tricky to determine which commits are new since it looks like the history in this branch has diverged from #1534 Are the commits unique to this branch just 2f24ce5, d90ff39 and 5c849ac?

@japaric
Copy link
Contributor Author

japaric commented Nov 27, 2023

@cpu only the last 3 commits. I have rebased the PR

@djc
Copy link
Member

djc commented Nov 28, 2023

For stacked PRs, I recommend setting the PR's base commit as the branch it's stacked on. This makes it much more obvious what's going on (and the PR's will be reset to main as soon as the base is merged).

@japaric
Copy link
Contributor Author

japaric commented Nov 28, 2023

@djc that's what I normally do when I can push branches into the repository where I'm submitting the PRs to but these PRs come from branches on my fork so I can't set the base to a branch in my fork and have the PR be visible on rustls/rustls; GitHub will open the PR in japaric/rustls where you won't see it / get notified

@ctz
Copy link
Member

ctz commented Dec 19, 2023

I rebased this.

rustls/src/conn.rs Show resolved Hide resolved
@@ -1032,7 +1032,8 @@ impl State<ClientConnectionData> for ExpectFinished {
emit_finished(&st.secrets, &mut st.transcript, cx.common);
}

cx.common.start_traffic();
cx.common
.start_traffic(cx.sendable_plaintext.as_deref_mut());
Copy link
Member

Choose a reason for hiding this comment

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

From looking at the diffs, it doesn't seem like we need as_deref_mut() here?

rustls/src/client/tls13.rs Show resolved Hide resolved
rustls/src/server/tls12.rs Show resolved Hide resolved
rustls/src/server/tls13.rs Show resolved Hide resolved
@@ -348,24 +356,29 @@ impl CommonState {
self.send_appdata_encrypt(data, limit)
}

pub(crate) fn start_outgoing_traffic(&mut self) {
pub(crate) fn start_outgoing_traffic(
Copy link
Member

Choose a reason for hiding this comment

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

Here, and for start_straffic(), it would be good to add a comment about when/why sendable_plaintext is None.

@@ -715,6 +728,7 @@ pub(crate) trait State<Data>: Send + Sync {
pub(crate) struct Context<'a, Data> {
pub(crate) common: &'a mut CommonState,
pub(crate) data: &'a mut Data,
pub(crate) sendable_plaintext: Option<&'a mut ChunkVecBuffer>,
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to add comments here too about the Some vs None cases.

@djc
Copy link
Member

djc commented Dec 19, 2023

This generally makes sense to me.

Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

Copy link

rustls-benchmarking bot commented Dec 19, 2023

Benchmark results

Instruction counts

Significant differences

There are no significant instruction count differences

Other differences

Click to expand
Scenario Baseline Candidate Diff Threshold
handshake_tickets_aws_lc_rs_1.2_rsa_aes_server 4660371 4622421 -37950 (-0.81%) 2.56%
handshake_session_id_aws_lc_rs_1.2_rsa_aes_server 4118450 4144570 26120 (0.63%) 4.37%
handshake_session_id_ring_1.2_rsa_aes_server 4421131 4415556 -5575 (-0.13%) 0.20%
handshake_tickets_ring_1.2_rsa_aes_server 4861337 4855650 -5687 (-0.12%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_aes_server 33607480 33571846 -35634 (-0.11%) 0.52%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha_server 33248903 33271739 22836 (0.07%) 0.67%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes_server 57155559 57191850 36291 (0.06%) 0.30%
handshake_session_id_aws_lc_rs_1.3_rsa_aes_server 33305765 33284759 -21006 (-0.06%) 0.45%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha_server 33603926 33585955 -17971 (-0.05%) 0.64%
handshake_no_resume_aws_lc_rs_1.3_ecdsa_chacha_client 5211785 5214163 2378 (0.05%) 0.20%
handshake_tickets_ring_1.2_rsa_aes_client 4731296 4729625 -1671 (-0.04%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsa_aes_server 33285725 33275343 -10382 (-0.03%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsa_chacha_server 33267106 33257090 -10016 (-0.03%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsa_aes_server 33538539 33528672 -9867 (-0.03%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsa_chacha_server 33550840 33541151 -9689 (-0.03%) 0.20%
handshake_tickets_aws_lc_rs_1.2_rsa_aes_client 4506989 4505748 -1241 (-0.03%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsa_aes_client 5210335 5211563 1228 (0.02%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha_server 12743460 12746450 2990 (0.02%) 1.07%
handshake_session_id_ring_1.3_rsa_aes_server 43678497 43668431 -10066 (-0.02%) 0.20%
handshake_session_id_ring_1.3_rsa_chacha_server 43612505 43602470 -10035 (-0.02%) 0.20%
handshake_session_id_ring_1.3_ecdsa_chacha_server 43619540 43609540 -10000 (-0.02%) 0.20%
handshake_tickets_ring_1.3_rsa_aes_server 43902570 43892543 -10027 (-0.02%) 0.20%
handshake_tickets_ring_1.3_rsa_chacha_server 43862577 43852581 -9996 (-0.02%) 0.20%
handshake_tickets_ring_1.3_ecdsa_chacha_server 43871024 43861067 -9957 (-0.02%) 0.20%
handshake_session_id_ring_1.3_ecdsa_aes_server 43685347 43675448 -9899 (-0.02%) 0.20%
handshake_tickets_ring_1.3_ecdsa_aes_server 43910787 43901023 -9764 (-0.02%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsa_chacha_client 31133891 31140283 6392 (0.02%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha_server 91377329 91394581 17252 (0.02%) 0.20%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes_server 57103987 57114632 10645 (0.02%) 0.34%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes_server 12732899 12730618 -2281 (-0.02%) 0.86%
handshake_no_resume_ring_1.3_ecdsa_aes_server 2133312 2132998 -314 (-0.01%) 0.20%
handshake_session_id_ring_1.2_rsa_aes_client 4441681 4441102 -579 (-0.01%) 0.20%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes_server 12359174 12360589 1415 (0.01%) 0.73%
handshake_tickets_aws_lc_rs_1.3_ecdsa_aes_client 31146973 31143917 -3056 (-0.01%) 0.20%
handshake_session_id_aws_lc_rs_1.2_rsa_aes_client 4168416 4168081 -335 (-0.01%) 0.20%
handshake_no_resume_ring_1.3_ecdsa_chacha_server 2135901 2135748 -153 (-0.01%) 0.20%
transfer_no_resume_ring_1.3_ecdsa_aes_client 57927557 57931014 3457 (0.01%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsa_chacha_client 30963802 30965577 1775 (0.01%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsa_aes_client 30969632 30968197 -1435 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes_client 57976203 57978856 2653 (0.00%) 0.20%
transfer_no_resume_ring_1.2_rsa_aes_client 57842342 57844958 2616 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsa_chacha_server 2056465 2056373 -92 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_aes_client 57942806 57945312 2506 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha_client 92430952 92434633 3681 (0.00%) 0.20%
handshake_no_resume_ring_1.2_rsa_aes_client 4442013 4442183 170 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes_client 68411192 68413680 2488 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha_client 3387968 3388091 123 (0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_aes_client 4538332 4538459 127 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsa_chacha_client 92370404 92367884 -2520 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsa_aes_client 42053136 42054276 1140 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes_client 3173440 3173525 85 (0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_aes_server 57103980 57102675 -1305 (-0.00%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_aes_client 31352818 31353523 705 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes_client 3377424 3377498 74 (0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsa_aes_client 42232735 42233660 925 (0.00%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha_client 31334750 31335402 652 (0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsa_aes_client 14417523 14417224 -299 (-0.00%) 0.20%
transfer_no_resume_ring_1.2_rsa_aes_server 56967965 56966788 -1177 (-0.00%) 0.20%
handshake_session_id_aws_lc_rs_1.3_rsa_aes_client 31163572 31164211 639 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsa_aes_server 57177074 57175975 -1099 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsa_aes_client 57967579 57966546 -1033 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsa_aes_server 57082726 57081719 -1007 (-0.00%) 0.20%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha_client 31114956 31115472 516 (0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_chacha_client 4548343 4548414 71 (0.00%) 0.20%
handshake_session_id_ring_1.3_rsa_chacha_client 42188598 42189248 650 (0.00%) 0.20%
handshake_tickets_ring_1.3_rsa_aes_client 42416006 42416657 651 (0.00%) 0.20%
handshake_tickets_ring_1.3_rsa_chacha_client 42380857 42381493 636 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsa_chacha_server 91247749 91246410 -1339 (-0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsa_chacha_client 42201893 42202504 611 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsa_chacha_server 91341882 91340610 -1272 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsa_chacha_client 42010719 42011278 559 (0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_chacha_server 12250746 12250586 -160 (-0.00%) 0.20%
handshake_session_id_ring_1.3_rsa_aes_client 42235503 42236030 527 (0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_chacha_server 91268269 91267257 -1012 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsa_chacha_client 92437487 92436587 -900 (-0.00%) 0.20%
handshake_no_resume_ring_1.2_rsa_aes_server 12044898 12044782 -116 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsa_chacha_client 14418068 14418182 114 (0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_aes_server 12240637 12240547 -90 (-0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsa_aes_server 2052495 2052482 -13 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_chacha_client 92384800 92385027 227 (0.00%) 0.20%

Wall-time

Significant differences

There are no significant wall-time differences

Other differences

Click to expand
Scenario Baseline Candidate Diff Threshold
transfer_no_resume_aws_lc_rs_1.3_rsa_aes 5.89 ms 5.86 ms -0.03 ms (-0.50%) 5.52%
transfer_no_resume_aws_lc_rs_1.3_ecdsa_aes 5.14 ms 5.11 ms -0.02 ms (-0.47%) 6.82%
handshake_session_id_aws_lc_rs_1.2_rsa_aes 2.09 ms 2.08 ms -0.01 ms (-0.45%) 1.44%
handshake_no_resume_ring_1.3_ecdsa_chacha 1.26 ms 1.26 ms 0.01 ms (0.44%) 1.00%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes 5.88 ms 5.86 ms -0.02 ms (-0.41%) 5.20%
transfer_no_resume_ring_1.3_rsa_aes 7.31 ms 7.28 ms -0.03 ms (-0.40%) 4.70%
handshake_tickets_ring_1.3_ecdsa_aes 7.57 ms 7.60 ms 0.03 ms (0.40%) 1.02%
handshake_tickets_ring_1.3_ecdsa_chacha 7.54 ms 7.57 ms 0.03 ms (0.38%) 1.00%
handshake_tickets_aws_lc_rs_1.2_rsa_aes 2.26 ms 2.25 ms -0.01 ms (-0.37%) 1.30%
handshake_session_id_ring_1.3_rsa_chacha 7.40 ms 7.43 ms 0.03 ms (0.36%) 1.00%
handshake_tickets_ring_1.3_rsa_aes 7.45 ms 7.48 ms 0.03 ms (0.35%) 1.00%
handshake_session_id_ring_1.3_ecdsa_chacha 7.53 ms 7.56 ms 0.03 ms (0.35%) 1.00%
handshake_no_resume_ring_1.3_ecdsa_aes 1.26 ms 1.27 ms 0.00 ms (0.34%) 1.17%
handshake_tickets_ring_1.3_rsa_chacha 7.42 ms 7.44 ms 0.02 ms (0.33%) 1.00%
handshake_session_id_ring_1.3_ecdsa_aes 7.56 ms 7.59 ms 0.02 ms (0.31%) 1.00%
transfer_no_resume_aws_lc_rs_1.3_ecdsa_chacha 13.62 ms 13.57 ms -0.04 ms (-0.30%) 2.42%
transfer_no_resume_ring_1.2_rsa_aes 7.22 ms 7.20 ms -0.02 ms (-0.30%) 4.09%
transfer_no_resume_ring_1.3_ecdsa_aes 7.48 ms 7.46 ms -0.02 ms (-0.28%) 4.53%
handshake_session_id_ring_1.3_rsa_aes 7.45 ms 7.47 ms 0.02 ms (0.27%) 1.00%
transfer_no_resume_ring_1.3_ecdsa_chacha 14.20 ms 14.17 ms -0.03 ms (-0.21%) 2.41%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha 14.37 ms 14.35 ms -0.03 ms (-0.19%) 2.15%
transfer_no_resume_ring_1.3_rsa_chacha 14.01 ms 13.99 ms -0.02 ms (-0.18%) 2.21%
handshake_tickets_aws_lc_rs_1.3_ecdsa_chacha 5.58 ms 5.59 ms 0.01 ms (0.17%) 1.00%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes 1.35 ms 1.35 ms -0.00 ms (-0.15%) 1.00%
handshake_session_id_aws_lc_rs_1.3_rsa_aes 6.39 ms 6.38 ms -0.01 ms (-0.14%) 1.00%
handshake_session_id_ring_1.2_rsa_aes 1.70 ms 1.70 ms 0.00 ms (0.12%) 1.57%
handshake_tickets_aws_lc_rs_1.3_rsa_aes 6.42 ms 6.41 ms -0.01 ms (-0.11%) 1.05%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes 1.41 ms 1.41 ms -0.00 ms (-0.08%) 1.00%
handshake_no_resume_ring_1.3_rsa_chacha 1.08 ms 1.08 ms -0.00 ms (-0.07%) 1.50%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha 1.40 ms 1.40 ms -0.00 ms (-0.06%) 1.04%
handshake_session_id_aws_lc_rs_1.3_ecdsa_aes 5.57 ms 5.57 ms -0.00 ms (-0.06%) 1.20%
handshake_session_id_aws_lc_rs_1.3_ecdsa_chacha 5.56 ms 5.56 ms 0.00 ms (0.05%) 1.06%
handshake_no_resume_ring_1.3_rsa_aes 1.08 ms 1.08 ms -0.00 ms (-0.05%) 1.60%
handshake_tickets_ring_1.2_rsa_aes 1.78 ms 1.79 ms 0.00 ms (0.05%) 1.38%
handshake_no_resume_aws_lc_rs_1.3_ecdsa_chacha 653.42 µs 653.68 µs 0.25 µs (0.04%) 2.72%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha 6.40 ms 6.40 ms 0.00 ms (0.03%) 1.05%
handshake_no_resume_ring_1.2_rsa_aes 1.07 ms 1.07 ms -0.00 ms (-0.03%) 1.45%
handshake_no_resume_aws_lc_rs_1.3_ecdsa_aes 655.42 µs 655.28 µs -0.14 µs (-0.02%) 2.58%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha 6.37 ms 6.37 ms 0.00 ms (0.01%) 1.00%
handshake_tickets_aws_lc_rs_1.3_ecdsa_aes 5.60 ms 5.60 ms 0.00 ms (0.01%) 1.27%

Additional information

Historical results

Checkout details:

@ctz ctz added this pull request to the merge queue Dec 20, 2023
Merged via the queue into rustls:main with commit f544352 Dec 20, 2023
22 of 23 checks passed
@tshepang tshepang deleted the mv-sendable-plaintext branch December 21, 2023 10:13
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.

None yet

5 participants