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

performance of openssl 1.1.1p vs. 3.1.0 #21005

Open
vitalyk-radware opened this issue May 19, 2023 · 10 comments
Open

performance of openssl 1.1.1p vs. 3.1.0 #21005

vitalyk-radware opened this issue May 19, 2023 · 10 comments
Labels
triaged: performance The issue/pr reports/fixes a performance concern

Comments

@vitalyk-radware
Copy link

vitalyk-radware commented May 19, 2023

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.

@vitalyk-radware vitalyk-radware added the issue: question The issue was opened to ask a question label May 19, 2023
@paulidale
Copy link
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.

@paulidale paulidale added triaged: question The issue contains a question resolved: answered The issue contained a question which has been answered and removed issue: question The issue was opened to ask a question labels May 21, 2023
@vitalyk-radware
Copy link
Author

vitalyk-radware commented May 21, 2023 via email

@mattcaswell
Copy link
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.

@Liu-ErMeng
Copy link
Contributor

Liu-ErMeng commented May 22, 2023

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.

@t8m
Copy link
Member

t8m commented May 23, 2023

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

@mattcaswell
Copy link
Member

Could refactoring to use EVP_MAC help?

Quite possibly. Not sure how easy it will be though

@mattcaswell
Copy link
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.

@Liu-ErMeng
Copy link
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

@mattcaswell
Copy link
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.

@vitalyk-radware
Copy link
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 ()

@paulidale paulidale added the triaged: performance The issue/pr reports/fixes a performance concern label Nov 7, 2023
@mattcaswell mattcaswell removed triaged: question The issue contains a question resolved: answered The issue contained a question which has been answered labels Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged: performance The issue/pr reports/fixes a performance concern
Projects
None yet
Development

No branches or pull requests

5 participants