Skip to content

performance of openssl 1.1.1p vs. 3.1.0  #21005

Open

Description

@rdwr-vitalyk

I compared performance of openssl versions 1.1.1p and 3.1.0 using nginx 1.23.4 as a server and siege 4.1.6 as a client.
I tried three ciphers and in each of these benchmarks, 1.1.1 has better performance.
Is it a well known issue or the tests are not correct?
Thank you!

                         1.1.1  hits     3.1.0 hits
AES256-SHA256                18728       8134
ECDHE-RSA-AES256-GCM-SHA384   16514    16015
ECDHE-ECDSA-AES256-GCM-SHA384   76020     64967

siege command is :

siege  -t1M -b  https://localhost:4411

p.s. All tools have been built with default config options; nginx webserver returns its default page.

Activity

  1. added
    issue: question
    on May 19, 2023
  2. paulidale commented on May 21, 2023

    @paulidale
    Contributor

    Yes, the performance loss is known. OpenSSL 3.x requires a slightly different approach and pre-fetching algorithms avoids the majority of the losses.

  3. added
    triaged: question
    resolved: answered
    and removed
    issue: question
    on May 21, 2023
  4. rdwr-vitalyk commented on May 21, 2023

    @rdwr-vitalyk
    Author
  5. mattcaswell commented on May 22, 2023

    @mattcaswell
    Member

    I read about explicit fetching, but we do not call functions like EVP_DigestInit() directly . It happens inside SSL…
    Therefore, I doubt how we can fetch algorithms in advance…

    If you are working mostly with libssl then the SSL_CTX will cache explicit fetches for you. Therefore it is important to re-use an SSL_CTX across multiple connections, i.e. do not create a new SSL_CTX for each SSL object.

  6. Liu-ErMeng commented on May 22, 2023

    @Liu-ErMeng
    Contributor

    Another point might help.
    According to the results of my testing and analysis,the specific cipher suite AES256-SHA256 invoke the tls1_mac in tls connection in both openssl1.x and openssl3.x. The performance of tls1_mac in openssl3.x dropes a lot compare to openssl1.x, it's because openssl3.x uses provider mechanism to implement mac instead, which has a longer calling path.

  7. t8m commented on May 23, 2023

    @t8m
    Member

    @mattcaswell it seems the tls1_mac still uses the old method of computing hmac through EVP_DigestSign? Could refactoring to use EVP_MAC help?

  8. mattcaswell commented on May 23, 2023

    @mattcaswell
    Member

    Could refactoring to use EVP_MAC help?

    Quite possibly. Not sure how easy it will be though

  9. mattcaswell commented on May 23, 2023

    @mattcaswell
    Member

    According to the results of my testing and analysis,the specific cipher suite AES256-SHA256 invoke the tls1_mac in tls connection in both openssl1.x and openssl3.x. The performance of tls1_mac in openssl3.x dropes a lot compare to openssl1.x, it's because openssl3.x uses provider mechanism to implement mac instead, which has a longer calling path.

    Do you have some statistics on the tls1_mac performance drop? And any details about how you did your testing would be helpful.

  10. Liu-ErMeng commented on May 23, 2023

    @Liu-ErMeng
    Contributor

    According to the results of my testing and analysis,the specific cipher suite AES256-SHA256 invoke the tls1_mac in tls connection in both openssl1.x and openssl3.x. The performance of tls1_mac in openssl3.x dropes a lot compare to openssl1.x, it's because openssl3.x uses provider mechanism to implement mac instead, which has a longer calling path.

    Do you have some statistics on the tls1_mac performance drop? And any details about how you did your testing would be helpful.

    Yes. It's the server-side perf data.
    openssl-3.0.7
    image
    openssl1.1.1n
    image

  11. mattcaswell commented on May 23, 2023

    @mattcaswell
    Member

    Hmmm. I don't understand the increase spent in SHA256_Update from 16.39 to 20.62. Most of the performance difference seems to be there.

  12. rdwr-vitalyk commented on May 24, 2023

    @rdwr-vitalyk
    Author

    I would like to ask about OPENSSL_LH_doall_arg / do_name functions.
    They are responsible for 2-5% of CPU time in my becnhmark test (server with cipher ECDHE-ECDSA-AES256-GCM-SHA384).
    Can we do anything to minimize their effect on performance?
    I understand it may be related to some "legacy" more of keys... is it true?

    below is a trace of these fnunctions:

    #0  0x00000000005d0690 in do_name ()
    #1  0x00000000005cee5c in OPENSSL_LH_doall_arg ()
    #2  0x00000000005d0888 in ossl_namemap_doall_names ()
    #3  0x00000000005c7827 in int_ctx_new.constprop ()
    #4  0x00000000005bf195 in do_sigver_init ()
    #5  0x00000000005bf3b3 in EVP_DigestSignInit_ex ()
    #6  0x00000000005c2a79 in EVP_PKEY_digestsign_supports_digest ()
    #7  0x0000000000521494 in check_cert_usable.isra ()
    #8  0x000000000052534c in tls_choose_sigalg ()
    #9  0x0000000000552822 in tls_post_process_client_hello ()
    #10 0x000000000053fd12 in state_machine ()
    #11 0x0000000000516834 in SSL_do_handshake ()
    
  13. added
    triaged: performance
    on Nov 7, 2023
  14. removed
    triaged: question
    resolved: answered
    on Jan 31, 2024
  15. levitte commented on Nov 19, 2026

    @levitte
    Member

    Is this issue still relevant? All versions that are mentioned are now past EOL. I'd like to move this to close, unless someone thinks differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triaged: performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions