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

fix no-std support #145

Merged
merged 3 commits into from
Aug 1, 2023
Merged

fix no-std support #145

merged 3 commits into from
Aug 1, 2023

Conversation

japaric
Copy link
Contributor

@japaric japaric commented Aug 1, 2023

this PR

  • makes the alloc feature not pull in the optional ring dependency
  • fixes cargo build --no-default-features --features alloc
  • adds a CI check to prevent no-std support breaking in the future

fixes #143
fixes #144

@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #145 (4948ea8) into main (aa818ab) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #145   +/-   ##
=======================================
  Coverage   96.01%   96.01%           
=======================================
  Files          15       15           
  Lines        4065     4065           
=======================================
  Hits         3903     3903           
  Misses        162      162           
Files Changed Coverage Δ
src/signed_data.rs 99.18% <ø> (ø)
src/crl.rs 99.65% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@japaric japaric force-pushed the fix-nostd branch 2 times, most recently from 190b894 to 575f25c Compare August 1, 2023 10:54
@japaric japaric force-pushed the fix-nostd branch 2 times, most recently from dc8911a to 7112ecc Compare August 1, 2023 11:04
@japaric japaric marked this pull request as ready for review August 1, 2023 11:06
src/crl.rs Outdated Show resolved Hide resolved
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.

Thanks!

I think the different performance characteristics of the BTreeMap vs HashMap are probably not significant enough in this use-case to merit trying to do more complicated abstraction to allow switching between the two based on features.

Running cargo bench on tip of main and on this branch shows that the BTreeMap-based owned representation is faster for the initial parsing of a chonky CRL and only a bit slower for lookups. I think it's a reasonable trade-off.

HashMap:

test bench_parse_owned_crl_large      ... bench: 517,452,454 ns/iter (+/- 98,860,890)
test bench_parse_owned_crl_medium     ... bench: 176,374,780 ns/iter (+/- 32,024,576)
test bench_parse_owned_crl_small      ... bench:     186,129 ns/iter (+/- 7,450)
test bench_search_owned_crl_large     ... bench:           9 ns/iter (+/- 3)
test bench_search_owned_crl_medium    ... bench:           9 ns/iter (+/- 3)
test bench_search_owned_crl_small     ... bench:          10 ns/iter (+/- 1)

BTreeMap:

test bench_parse_owned_crl_large      ... bench: 296,112,924 ns/iter (+/- 37,342,479)
test bench_parse_owned_crl_medium     ... bench:  89,594,215 ns/iter (+/- 13,807,766)
test bench_parse_owned_crl_small      ... bench:     175,042 ns/iter (+/- 19,676)
test bench_search_owned_crl_large     ... bench:          63 ns/iter (+/- 16)
test bench_search_owned_crl_medium    ... bench:          69 ns/iter (+/- 13)
test bench_search_owned_crl_small     ... bench:          50 ns/iter (+/- 2)

@djc
Copy link
Member

djc commented Aug 1, 2023

To be fair, lookups are like 7x slower with a BTreeMap, but that penalty probably gets lost in the noise of actual crypto operations.

@cpu
Copy link
Member

cpu commented Aug 1, 2023

@ctz Thoughts? Ready for merge queue?

@ctz ctz added this pull request to the merge queue Aug 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 1, 2023
@ctz ctz added this pull request to the merge queue Aug 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 1, 2023
@cpu cpu added this pull request to the merge queue Aug 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 1, 2023
@cpu
Copy link
Member

cpu commented Aug 1, 2023

I'm going to bypass the merge queue for this one while the dependency fetching flake is happening. It keeps getting bounced from the queue 🎰

@cpu cpu merged commit 29dca49 into rustls:main Aug 1, 2023
24 checks passed
@japaric japaric deleted the fix-nostd branch August 3, 2023 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants