Content-Length: 462784 | pFad | http://github.com/rustls/rustls/pull/2669

61 Use generics instead of enum wrappers for connection types by djc · Pull Request #2669 · rustls/rustls · GitHub
Skip to content

Use generics instead of enum wrappers for connection types#2669

Open
djc wants to merge 8 commits intomainfrom
generic-conn
Open

Use generics instead of enum wrappers for connection types#2669
djc wants to merge 8 commits intomainfrom
generic-conn

Conversation

@djc
Copy link
Member

@djc djc commented Sep 23, 2025

Replaces ClientConnection with Connection<Client>, which seems like a pretty nice way to move forward. Makes generics quite a bit simpler: instead of impl DerefMut<Target = ConnectionCommon<impl SideData>> we can now say ConnectionCommon<impl SideData>).

Remaining steps:

  • QUIC
  • Unbuffered

Maybe having Client and Server types is a little weird and they should be ClientData and ServerData?

Would like early feedback before resolving all CI issues.

@djc djc requested review from cpu and ctz September 23, 2025 09:45
@rustls-benchmarking
Copy link

rustls-benchmarking bot commented Sep 23, 2025

Benchmark results

Instruction counts

Significant differences

⚠️ There are significant instruction count differences

Click to expand
Scenario Baseline Candidate Diff Threshold
handshake_session_id_1.3_no_crypto_client 2200449 2185929 -14520 (-0.66%) 0.20%
handshake_tickets_1.3_no_crypto_client 2217249 2202729 -14520 (-0.65%) 0.20%
handshake_session_id_1.2_no_crypto_client 1125917 1118777 -7140 (-0.63%) 0.33%
handshake_tickets_1.2_no_crypto_client 1211562 1204422 -7140 (-0.59%) 0.47%
handshake_session_id_ring_1.2_rsa_aes_client 3401386 3394246 -7140 (-0.21%) 0.20%

Other differences

Click to expand
Scenario Baseline Candidate Diff Threshold
handshake_session_id_aws_lc_rs_1.3_rsa_chacha_client 52866575 52658684 -207891 (-0.39%) 0.74%
handshake_session_id_aws_lc_rs_1.3_rsa_aes_client 52840356 52669193 -171163 (-0.32%) 0.46%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_aes_client 52809807 52651401 -158406 (-0.30%) 0.72%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_aes_client 53059366 52900805 -158561 (-0.30%) 0.67%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha_client 53002108 52853712 -148396 (-0.28%) 0.55%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_chacha_client 52654251 52799992 145741 (0.28%) 0.69%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_chacha_client 53031760 52885655 -146105 (-0.28%) 0.64%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha_server 42585235 42485709 -99526 (-0.23%) 0.43%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_chacha_client 52664903 52784029 119126 (0.23%) 0.57%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_aes_client 9136183 9155705 19522 (0.21%) 1.30%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_client 9140554 9159534 18980 (0.21%) 0.75%
handshake_session_id_aws_lc_rs_1.3_rsa_aes_server 42622047 42539988 -82059 (-0.19%) 0.31%
handshake_tickets_ring_1.2_rsa_aes_client 3790318 3783178 -7140 (-0.19%) 0.20%
handshake_session_id_aws_lc_rs_1.2_rsa_aes_client 3818180 3811040 -7140 (-0.19%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_chacha_server 42488507 42566030 77523 (0.18%) 0.45%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_aes_server 42615784 42541122 -74662 (-0.18%) 0.49%
handshake_tickets_aws_lc_rs_1.2_rsa_aes_client 4208320 4201180 -7140 (-0.17%) 0.20%
handshake_tickets_1.3_no_crypto_server 2060754 2057394 -3360 (-0.16%) 0.22%
handshake_session_id_1.3_no_crypto_server 2095741 2092381 -3360 (-0.16%) 0.22%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_chacha_server 42494297 42558495 64198 (0.15%) 0.36%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_aes_server 43968507 43902185 -66322 (-0.15%) 0.41%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes_server 11143979 11128465 -15514 (-0.14%) 1.38%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha_server 43900800 43839876 -60924 (-0.14%) 0.36%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_chacha_server 43925018 43865132 -59886 (-0.14%) 0.38%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha_server 11161745 11149280 -12465 (-0.11%) 1.14%
handshake_tickets_aws_lc_rs_1.2_rsa_aes_server 4829371 4833661 4290 (0.09%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_aes_client 52982826 53028458 45632 (0.09%) 0.51%
handshake_tickets_aws_lc_rs_1.3_rsa_aes_server 43920587 43955262 34675 (0.08%) 0.31%
handshake_no_resume_1.3_no_crypto_server 100156 100084 -72 (-0.07%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_client 3929952 3932709 2757 (0.07%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_chacha_server 43852978 43882972 29994 (0.07%) 0.30%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_chacha_client 52884642 52918284 33642 (0.06%) 0.49%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_aes_client 52927981 52902568 -25413 (-0.05%) 0.53%
handshake_session_id_ring_1.3_ecdsap384_chacha_client 30358928 30344408 -14520 (-0.05%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_chacha_client 30362281 30347761 -14520 (-0.05%) 0.20%
handshake_session_id_ring_1.3_rsa_chacha_client 30365907 30351387 -14520 (-0.05%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_aes_client 30450578 30436058 -14520 (-0.05%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_aes_client 30453931 30439411 -14520 (-0.05%) 0.20%
handshake_session_id_ring_1.3_rsa_aes_client 30457557 30443037 -14520 (-0.05%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_chacha_client 30485470 30470950 -14520 (-0.05%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_chacha_client 30488177 30473657 -14520 (-0.05%) 0.20%
handshake_tickets_ring_1.3_rsa_chacha_client 30492323 30477803 -14520 (-0.05%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_aes_client 30557680 30543160 -14520 (-0.05%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_aes_client 30560408 30545888 -14520 (-0.05%) 0.20%
handshake_tickets_ring_1.3_rsa_aes_client 30564554 30550034 -14520 (-0.05%) 0.20%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes_server 10448709 10453426 4717 (0.05%) 1.40%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_aes_client 52677866 52698905 21039 (0.04%) 0.54%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_aes_server 42549061 42564327 15266 (0.04%) 0.33%
handshake_no_resume_1.3_no_crypto_client 101439 101464 25 (0.02%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_aes_server 1574253 1573897 -356 (-0.02%) 0.20%
handshake_no_resume_1.2_no_crypto_client 91676 91696 20 (0.02%) 0.20%
handshake_session_id_ring_1.2_rsa_aes_server 3306488 3305778 -710 (-0.02%) 0.29%
handshake_tickets_ring_1.2_rsa_aes_server 3905336 3904616 -720 (-0.02%) 0.25%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_server 1576551 1576316 -235 (-0.01%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_aes_client 3929439 3929989 550 (0.01%) 0.24%
handshake_no_resume_1.2_no_crypto_server 73498 73506 8 (0.01%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_chacha_server 31534517 31531127 -3390 (-0.01%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_chacha_server 31534537 31531147 -3390 (-0.01%) 0.20%
handshake_session_id_ring_1.3_rsa_chacha_server 31534637 31531247 -3390 (-0.01%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_aes_server 31656707 31653317 -3390 (-0.01%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_aes_server 31656727 31653337 -3390 (-0.01%) 0.20%
handshake_session_id_ring_1.3_rsa_aes_server 31656827 31653437 -3390 (-0.01%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_chacha_server 31861612 31858222 -3390 (-0.01%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_chacha_server 31861724 31858334 -3390 (-0.01%) 0.20%
handshake_tickets_ring_1.3_rsa_chacha_server 31861726 31858336 -3390 (-0.01%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_aes_server 31964572 31961182 -3390 (-0.01%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_aes_server 31964684 31961294 -3390 (-0.01%) 0.20%
handshake_tickets_ring_1.3_rsa_aes_server 31964686 31961296 -3390 (-0.01%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_server 2486395 2486186 -209 (-0.01%) 0.20%
handshake_no_resume_ring_1.3_ecdsap256_chacha_server 1281562 1281468 -94 (-0.01%) 0.20%
handshake_no_resume_ring_1.3_ecdsap256_aes_server 1280374 1280304 -70 (-0.01%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha_client 2768747 2768882 135 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_aes_server 2483265 2483180 -85 (-0.00%) 0.32%
handshake_session_id_1.2_no_crypto_server 1023998 1023968 -30 (-0.00%) 0.56%
handshake_no_resume_ring_1.3_ecdsap256_chacha_client 3294627 3294547 -80 (-0.00%) 0.24%
handshake_no_resume_ring_1.3_ecdsap256_aes_client 3293241 3293309 68 (0.00%) 0.25%
handshake_no_resume_ring_1.3_rsa_aes_client 2327405 2327434 29 (0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_chacha_client 2333059 2333088 29 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes_client 1716011 1716032 21 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes_client 2762037 2762004 -33 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_aes_client 58063504 58062855 -649 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_aes_client 58073632 58072988 -644 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes_client 58113731 58113089 -642 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes_client 58191244 58190604 -640 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_aes_client 58182698 58182059 -639 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_aes_client 58182281 58181644 -637 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_aes_client 58061945 58061310 -635 (-0.00%) 0.20%
handshake_no_resume_ring_1.2_rsa_aes_client 2202942 2202966 24 (0.00%) 0.20%
transfer_no_resume_ring_1.2_rsa_aes_client 57954705 57954076 -629 (-0.00%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_aes_server 43901381 43901846 465 (0.00%) 0.33%
handshake_no_resume_ring_1.3_ecdsap384_aes_server 7214532 7214456 -76 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_chacha_server 7216493 7216420 -73 (-0.00%) 0.20%
handshake_session_id_aws_lc_rs_1.2_rsa_aes_server 3725999 3725969 -30 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_client 92642865 92642218 -647 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha_client 92652686 92652048 -638 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_chacha_client 92588937 92588301 -636 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_chacha_client 92589303 92588671 -632 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_chacha_client 92599069 92598437 -632 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_client 92642439 92641808 -631 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_aes_server 11110601 11110528 -73 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_chacha_server 11116355 11116282 -73 (-0.00%) 0.20%
transfer_no_resume_1.2_no_crypto_client 117355103 117354461 -642 (-0.00%) 0.20%
transfer_no_resume_1.3_no_crypto_client 117407326 117406690 -636 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_aes_server 46009660 46009790 130 (0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_aes_server 45998984 45999113 129 (0.00%) 0.20%
transfer_no_resume_ring_1.2_rsa_aes_server 45901596 45901720 124 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_aes_server 46001590 46001713 123 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes_server 46111145 46111266 121 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_aes_server 46170781 46170902 121 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_aes_server 46162176 46162295 119 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes_server 46167487 46167606 119 (0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_chacha_server 80233863 80233991 128 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_chacha_server 80244543 80244670 127 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha_server 80347962 80348088 126 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_server 80350630 80350752 122 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_chacha_server 80238400 80238516 116 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_server 80342023 80342137 114 (0.00%) 0.20%
transfer_no_resume_1.3_no_crypto_server 105021804 105021926 122 (0.00%) 0.20%
transfer_no_resume_1.2_no_crypto_server 104969577 104969697 120 (0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_chacha_client 34735643 34735670 27 (0.00%) 0.20%
handshake_no_resume_ring_1.2_rsa_aes_server 10955713 10955721 8 (0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_aes_client 34733917 34733937 20 (0.00%) 0.20%
handshake_tickets_1.2_no_crypto_server 1190748 1190748 0 (0.00%) 0.51%

Wall-time

Significant differences

There are no significant wall-time differences

Other differences

Click to expand
Scenario Baseline Candidate Diff Threshold
handshake_session_id_1.2_no_crypto 345.78 µs 332.09 µs -13.68 µs (-3.96%) 6.16%
handshake_tickets_1.2_no_crypto 379.45 µs 364.65 µs -14.79 µs (-3.90%) 4.89%
handshake_tickets_1.3_no_crypto 629.93 µs 615.71 µs -14.23 µs (-2.26%) 4.88%
handshake_session_id_1.3_no_crypto 653.08 µs 639.97 µs -13.12 µs (-2.01%) 5.39%
handshake_no_resume_1.3_no_crypto 86.04 µs 84.41 µs -1.64 µs (-1.90%) 5.84%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_aes 4.60 ms 4.54 ms -0.07 ms (-1.41%) 3.21%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_aes 5.30 ms 5.23 ms -0.07 ms (-1.24%) 2.79%
handshake_no_resume_1.2_no_crypto 78.14 µs 77.26 µs -0.88 µs (-1.12%) 6.45%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes 5.26 ms 5.20 ms -0.06 ms (-1.11%) 3.16%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes 5.09 ms 5.03 ms -0.05 ms (-1.08%) 3.72%
transfer_no_resume_ring_1.3_ecdsap256_aes 5.41 ms 5.35 ms -0.06 ms (-1.07%) 2.39%
handshake_session_id_ring_1.2_rsa_aes 1.41 ms 1.40 ms -0.01 ms (-0.99%) 1.23%
transfer_no_resume_ring_1.2_rsa_aes 5.81 ms 5.76 ms -0.05 ms (-0.91%) 2.15%
transfer_no_resume_ring_1.3_rsa_aes 5.89 ms 5.84 ms -0.05 ms (-0.91%) 2.04%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_chacha 7.30 ms 7.24 ms -0.06 ms (-0.87%) 1.31%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_chacha 7.98 ms 7.91 ms -0.07 ms (-0.84%) 1.22%
handshake_tickets_ring_1.3_ecdsap256_chacha 5.45 ms 5.41 ms -0.04 ms (-0.80%) 1.00%
handshake_session_id_ring_1.3_ecdsap256_chacha 5.40 ms 5.36 ms -0.04 ms (-0.80%) 1.00%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha 7.96 ms 7.90 ms -0.06 ms (-0.77%) 1.37%
handshake_tickets_ring_1.3_rsa_chacha 5.94 ms 5.90 ms -0.04 ms (-0.75%) 1.00%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_aes 7.32 ms 7.26 ms -0.05 ms (-0.74%) 1.41%
handshake_session_id_ring_1.3_rsa_chacha 5.89 ms 5.84 ms -0.04 ms (-0.72%) 1.00%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_chacha 7.48 ms 7.43 ms -0.05 ms (-0.72%) 1.23%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha 8.16 ms 8.10 ms -0.06 ms (-0.71%) 1.43%
handshake_session_id_ring_1.3_ecdsap256_aes 5.42 ms 5.39 ms -0.04 ms (-0.71%) 1.00%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_aes 8.00 ms 7.94 ms -0.06 ms (-0.70%) 1.57%
handshake_tickets_ring_1.2_rsa_aes 1.50 ms 1.49 ms -0.01 ms (-0.70%) 1.52%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_chacha 541.91 µs 538.18 µs -3.74 µs (-0.69%) 2.28%
transfer_no_resume_ring_1.3_ecdsap384_aes 8.51 ms 8.45 ms -0.06 ms (-0.68%) 1.67%
handshake_session_id_aws_lc_rs_1.3_rsa_aes 7.99 ms 7.94 ms -0.05 ms (-0.67%) 1.48%
handshake_tickets_ring_1.3_ecdsap256_aes 5.48 ms 5.44 ms -0.04 ms (-0.65%) 1.00%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_chacha 8.17 ms 8.12 ms -0.05 ms (-0.64%) 1.16%
handshake_tickets_ring_1.3_rsa_aes 5.97 ms 5.93 ms -0.04 ms (-0.62%) 1.00%
transfer_no_resume_1.2_no_crypto 11.78 ms 11.70 ms -0.07 ms (-0.62%) 1.26%
handshake_session_id_ring_1.3_rsa_aes 5.92 ms 5.88 ms -0.04 ms (-0.61%) 1.00%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_aes 544.37 µs 541.14 µs -3.23 µs (-0.59%) 2.11%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_aes 7.48 ms 7.44 ms -0.04 ms (-0.59%) 1.35%
handshake_no_resume_ring_1.3_ecdsap256_aes 462.80 µs 460.37 µs -2.43 µs (-0.53%) 2.05%
handshake_tickets_aws_lc_rs_1.3_rsa_aes 8.16 ms 8.11 ms -0.04 ms (-0.52%) 1.33%
transfer_no_resume_ring_1.3_ecdsap256_chacha 12.97 ms 12.91 ms -0.06 ms (-0.49%) 1.00%
handshake_session_id_ring_1.3_ecdsap384_chacha 8.49 ms 8.45 ms -0.04 ms (-0.49%) 1.00%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_aes 8.17 ms 8.13 ms -0.04 ms (-0.48%) 1.31%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_chacha 14.01 ms 13.95 ms -0.07 ms (-0.47%) 1.07%
handshake_tickets_ring_1.3_ecdsap384_chacha 8.55 ms 8.51 ms -0.04 ms (-0.47%) 1.00%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_chacha 13.32 ms 13.26 ms -0.06 ms (-0.46%) 1.27%
transfer_no_resume_ring_1.3_rsa_chacha 13.46 ms 13.40 ms -0.06 ms (-0.45%) 1.02%
handshake_session_id_ring_1.3_ecdsap384_aes 8.51 ms 8.47 ms -0.04 ms (-0.44%) 1.00%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha 13.98 ms 13.92 ms -0.06 ms (-0.44%) 1.45%
handshake_no_resume_ring_1.3_ecdsap256_chacha 458.12 µs 456.15 µs -1.97 µs (-0.43%) 1.84%
transfer_no_resume_ring_1.3_ecdsap384_chacha 16.08 ms 16.01 ms -0.06 ms (-0.40%) 1.00%
transfer_no_resume_1.3_no_crypto 11.83 ms 11.79 ms -0.05 ms (-0.39%) 1.32%
handshake_tickets_ring_1.3_ecdsap384_aes 8.57 ms 8.54 ms -0.03 ms (-0.37%) 1.00%
handshake_no_resume_ring_1.3_rsa_chacha 950.76 µs 947.93 µs -2.83 µs (-0.30%) 1.00%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_aes 1.23 ms 1.23 ms -0.00 ms (-0.30%) 1.06%
handshake_no_resume_ring_1.2_rsa_aes 941.91 µs 939.53 µs -2.38 µs (-0.25%) 1.00%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_chacha 1.23 ms 1.22 ms -0.00 ms (-0.24%) 1.00%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes 1.20 ms 1.19 ms -0.00 ms (-0.19%) 5.44%
handshake_no_resume_ring_1.3_rsa_aes 948.60 µs 946.95 µs -1.65 µs (-0.17%) 1.00%
handshake_session_id_aws_lc_rs_1.2_rsa_aes 1.61 ms 1.60 ms -0.00 ms (-0.10%) 3.73%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes 1.06 ms 1.06 ms -0.00 ms (-0.07%) 6.67%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha 1.19 ms 1.19 ms -0.00 ms (-0.07%) 6.27%
handshake_tickets_aws_lc_rs_1.2_rsa_aes 1.77 ms 1.77 ms 0.00 ms (0.05%) 4.60%
handshake_no_resume_ring_1.3_ecdsap384_aes 3.56 ms 3.56 ms -0.00 ms (-0.03%) 1.00%
handshake_no_resume_ring_1.3_ecdsap384_chacha 3.56 ms 3.55 ms -0.00 ms (-0.02%) 1.00%

Additional information

Historical results

Checkout details:

@djc djc force-pushed the generic-conn branch 2 times, most recently from c4410d8 to 922b501 Compare September 23, 2025 10:29
@codecov
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.90%. Comparing base (3374299) to head (58a7c0b).

Files with missing lines Patch % Lines
rustls/src/server/server_conn.rs 84.21% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2669      +/-   ##
==========================================
+ Coverage   94.81%   94.90%   +0.08%     
==========================================
  Files          96       96              
  Lines       21826    21710     -116     
  Branches      614      614              
==========================================
- Hits        20695    20604      -91     
+ Misses       1003      978      -25     
  Partials      128      128              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ctz
Copy link
Member

ctz commented Sep 23, 2025

I'm not super sure about this. I had a look at this branch in terms of docs, autocomplete and llvm-lines output:

For docs, the first docs for the most important type in the whole library looks like:

image

Aside from knowing to scroll halfway down the page, and finding impl Connection<Server> etc, there is really no way to go from here to understanding what types for Data are acceptable, or where to find them, or what precisely to write to get something working (either as a value, or a type, or what constructors are available for this type.) Apparently rustdoc outputs these in the order they are encountered in, so maybe it's under our control to have impl Connection<Client> appear "above the fold"?

Autocomplete - rust-analyzer gleefully guides you to code that doesn't actually compile, like:

let mut conn = rustls::Connection::new(Arc::new(config), server_name).unwrap();

(and then leaves you to read the compiler error and follow one of the two suggestions, only one of which can ever produce code that compiles.)

For llvm-lines for the bogo runner, this grows lines from 38k to 41k, and most of that is coming from the entirely of bogo::exec being monomorphised an extra time.

Generally I think I have a visceral reaction to generics in rust, and I will avoid them at all costs, so take this with a pinch of salt.

@djc
Copy link
Member Author

djc commented Sep 23, 2025

I'm not super sure about this.

Totally fair, and I'm okay with abandoning this PR if we decide it's not an improvement. I think I still like it despite your concerns, so will argue with your points a little:

I had a look at this branch in terms of docs, autocomplete and llvm-lines output:

For docs, the first docs for the most important type in the whole library looks like:

[cut the screenshot]

Aside from knowing to scroll halfway down the page, and finding impl Connection<Server> etc, there is really no way to go from here to understanding what types for Data are acceptable, or where to find them, or what precisely to write to get something working (either as a value, or a type, or what constructors are available for this type.) Apparently rustdoc outputs these in the order they are encountered in, so maybe it's under our control to have impl Connection<Client> appear "above the fold"?

Well, the first problem here is that there is no meaningful doc string for Connection because it used to be a mostly internal type. Here's a screenshot of what it looks like when that is cleaned up a bit. Note that this renames the overly generic Data type argument to Side to make it more obvious, and adds eager bounds to make it clearer as well. (Implemented in later commits.)

Screenshot 2025-09-23 at 15 00 50

I agree that construction is less ergonomic, and that this is an important entry point, and rustdoc mostly does a decent job with representing the cascade of Deref implementations from ClientConfig -> ConnectionCommon<ClientConnectionData> -> CommonState. Apart from the constructors, arguably the generic methods for Connection are more relevant to most users than the side-specific ones, so I'd consider that a small win.

Autocomplete - rust-analyzer gleefully guides you to code that doesn't actually compile, like:

let mut conn = rustls::Connection::new(Arc::new(config), server_name).unwrap();

(and then leaves you to read the compiler error and follow one of the two suggestions, only one of which can ever produce code that compiles.)

Right. As a potential workaround, we could move these methods to the Config types instead. That would have the slight advantage of enabling chaining in the case where you only need a single connection.

For llvm-lines for the bogo runner, this grows lines from 38k to 41k, and most of that is coming from the entirely of bogo::exec being monomorphised an extra time.

It feels to me like abstracting over connections to the degree that bogo does it is pretty rare and probably shouldn't be a heavily weighted factor in deciding how to proceed with this. I think making it more obvious how to abstract over both types of connections has some value that might help in downstream crates (like tokio-rustls), and generally feels nicer to me in the sense of exposing our internal abstractions. I also feel like it opens up potential avenues for finding better ways to abstract over buffered/unbuffered/QUIC connections.

Generally I think I have a visceral reaction to generics in rust, and I will avoid them at all costs, so take this with a pinch of salt.

I'd be curious if you can unpack this more. In general we're already using them a fair amount (for Deref tower), and I feel like that is largely better (mostly, easier to maintain) than duplicating wrappers all over the place -- or using macros, which I guess I have more of a visceral reaction to!

@djc
Copy link
Member Author

djc commented Sep 23, 2025

I'm not super sure about this.

Do you think we should invite the Maston/Bluesky mob to give feedback?

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.

2 participants









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/rustls/rustls/pull/2669

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy