Skip to content

der: rewrite der_ord as match without try! ? operator#1799

Merged
tarcieri merged 1 commit into
RustCrypto:masterfrom
dishmaker:dishmaker/der_cmp_llvm_ir
May 4, 2025
Merged

der: rewrite der_ord as match without try! ? operator#1799
tarcieri merged 1 commit into
RustCrypto:masterfrom
dishmaker:dishmaker/der_cmp_llvm_ir

Conversation

@dishmaker

Copy link
Copy Markdown
Contributor

Fixes #1798

Should produce faster compile times for anything using der.

x509-cert with new der_ord:

./formats$ CARGO_PROFILE_RELEASE_LTO=fat cargo llvm-lines --release -p x509-cert | head -20
  Lines                Copies              Function name
  -----                ------              -------------
  58324                1305                (TOTAL)
   2241 (3.8%,  3.8%)    12 (0.9%,  0.9%)  <der::reader::slice::SliceReader as der::reader::Reader>::read_nested
   1826 (3.1%,  7.0%)    24 (1.8%,  2.8%)  <core::ops::index_range::IndexRange as core::iter::traits::iterator::Iterator>::try_fold
   1711 (2.9%,  9.9%)    59 (4.5%,  7.3%)  <T as der::encode::Encode>::encoded_len
   1668 (2.9%, 12.8%)    12 (0.9%,  8.2%)  der::ord::iter_cmp
   1663 (2.9%, 15.6%)    23 (1.8%, 10.0%)  core::iter::traits::iterator::Iterator::try_fold
   1597 (2.7%, 18.4%)    13 (1.0%, 11.0%)  <T as der::decode::Decode>::decode
   1343 (2.3%, 20.7%)    14 (1.1%, 12.0%)  <der::reader::slice::SliceReader as der::reader::Reader>::finish
   1176 (2.0%, 22.7%)    21 (1.6%, 13.6%)  der::encode::EncodeValue::header
   1167 (2.0%, 24.7%)     1 (0.1%, 13.7%)  x509_cert::attr::AttributeTypeAndValue::from_delimited_str
   1160 (2.0%, 26.7%)    20 (1.5%, 15.2%)  <T as der::ord::DerOrd>::der_cmp
    891 (1.5%, 28.2%)     1 (0.1%, 15.3%)  <x509_cert::attr::AttributeTypeAndValue as core::fmt::Display>::fmt
    852 (1.5%, 29.7%)    12 (0.9%, 16.2%)  <der::asn1::context_specific::ContextSpecific<T> as der::tag::Tagged>::tag
    843 (1.4%, 31.1%)     3 (0.2%, 16.5%)  der::encode::Encode::encode_to_vec
    675 (1.2%, 32.3%)    15 (1.1%, 17.6%)  <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::next
    664 (1.1%, 33.4%)     8 (0.6%, 18.2%)  <T as der::encode::Encode>::encode
    624 (1.1%, 34.5%)    12 (0.9%, 19.2%)  <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
    564 (1.0%, 35.4%)    12 (0.9%, 20.1%)  <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::new

@tarcieri tarcieri merged commit 4d123e6 into RustCrypto:master May 4, 2025
107 checks passed
@tarcieri

tarcieri commented May 4, 2025

Copy link
Copy Markdown
Member

@dishmaker retroactive thought: you could maybe try adding an #[inline] annotation and see if that improves inlining

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.

der: der_cmp generates a lot of llvm-ir

2 participants