Skip to content

key exchange performance degradation #9063

@jtougas

Description

@jtougas

We've noticed a substantial degradation of performance in the key exchange portion of a ssh connection setup using asyncssh after upgrading cryptography from 40.0.2 to 41.0.0.

Full reproduction is available here here.

Here are some numbers that stood out from some profiling the same test case with version 41 vs 40:

crypto-41.prof

         1516341 function calls (1403297 primitive calls) in 2.502 seconds

   Ordered by: cumulative time
   List reduced from 6481 to 6416 due to restriction <0.99>
   List reduced from 6416 to 390 due to restriction <'cryptography'>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.379    0.379 /workspaces/project/.venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py:50(parameters)
        1    0.000    0.000    0.379    0.379 /workspaces/project/.venv/lib/python3.10/site-packages/cryptography/hazmat/backends/openssl/backend.py:1479(load_dh_parameter_numbers)
        1    0.000    0.000    0.199    0.199 /workspaces/project/.venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py:92(public_key)

crypto-40.prof

         1529613 function calls (1416401 primitive calls) in 2.011 seconds

   Ordered by: cumulative time
   List reduced from 6539 to 6474 due to restriction <0.99>
   List reduced from 6474 to 431 due to restriction <'cryptography'>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.037    0.037 /workspaces/project/.venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/ciphers/aead.py:1(<module>)
        1    0.000    0.000    0.037    0.037 /workspaces/project/.venv/lib/python3.10/site-packages/cryptography/hazmat/backends/openssl/__init__.py:1(<module>)
        1    0.000    0.000    0.036    0.036 /workspaces/project/.venv/lib/python3.10/site-packages/cryptography/hazmat/backends/openssl/backend.py:1(<module>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions