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

perf: don't check for peer certificate chain APIs on CPython/PyPy #171

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

ichard26
Copy link
Contributor

@ichard26 ichard26 commented Feb 1, 2025

create_default_context() is quite slow on Linux as OpenSSL 3.x verify location loading is painfully slow. I've observed ~15 ms per call.

On CPython and PyPy, we can skip this check since we already know the required APIs exist.

This is part of my goal of reducing pip's startup time.

create_default_context() is quite slow on Linux as OpenSSL 3.x
verify location loading is painfully slow. I've observed ~15 ms per
call.

On CPython and PyPy, we can skip this check since we already know
the required APIs exist.
@ichard26
Copy link
Contributor Author

ichard26 commented Feb 1, 2025

While I'm here, is SSLContext safe to reuse across requests sessions? Each SSLContext takes ~15 ms to create as we need to load the certifi bundle (invoking the same slow OpenSSL APIs). If we can reuse the same context across sessions, that'd be great!

@ichard26
Copy link
Contributor Author

ichard26 commented Feb 1, 2025

Not sure why the test suite is failing. It fails locally on main as well.

Copy link
Owner

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! Thanks for contributing this! Happy to receive more PRs that improve pip's performance.

@sethmlarson
Copy link
Owner

While I'm here, is SSLContext safe to reuse across requests sessions? Each SSLContext takes ~15 ms to create as we need to load the certifi bundle (invoking the same slow OpenSSL APIs). If we can reuse the same context across sessions, that'd be great!

I think it's safe to reuse but I am not certain about thread safety ?

@ichard26
Copy link
Contributor Author

ichard26 commented Feb 2, 2025

pip isn't multi-threaded yet ;)

*actually we use Rich which AFAIU does use a separate rendering thread but I can't imagine it'd be performing network requests.

@sethmlarson
Copy link
Owner

Failing test appears to be a change in Cloudflare DNS

@sethmlarson sethmlarson merged commit 7daa92e into sethmlarson:main Feb 2, 2025
4 of 19 checks passed
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.

2 participants