Add aiofastnet to speedups extra#12822
Conversation
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12822 +/- ##
==========================================
- Coverage 98.95% 98.78% -0.18%
==========================================
Files 131 131
Lines 47998 48047 +49
Branches 2494 2503 +9
==========================================
- Hits 47498 47463 -35
- Misses 376 444 +68
- Partials 124 140 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will improve performance by 51.36%
|
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
@codspeedbot explain why this is faster |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
… tests pass with aiofastnet
| _T_OnChunkSent = Optional[Callable[[bytes], Awaitable[None]]] | ||
|
|
||
|
|
||
| async def sendfile( |
There was a problem hiding this comment.
I think for these ones which are only referenced a single time, it probably makes more sense to do this inline, rather than wrapping the logic into a function.
| # aiofastnet is using sendfile on a non-blocking socket. | ||
| # blockbuster triggers anyway. Seems like a false positive | ||
| bb.functions["os.sendfile"].deactivate() |
There was a problem hiding this comment.
I'm unclear what all the changes in this file are about.
|
Looks to me like the PR is almost ready? |
I've made a new PR instead of #12744
What do these changes do?
Discussion #12701
This change adds
aiofastnettospeedupsextras.aiofastnetprovides more efficient implementations foraiohttpwill use them ifaiofastnetcan be imported.On top of that,
aiofastnetprovides optional, transparent Kernel TLS support on Linux and native sendfile for TLS connections using SSL_sendfile. User can enable it via the standard ssl.OP_ENABLE_KTLS option in SSLContext.Are there changes in behavior for the user?
This is an optimization change, it should not change visible behavior.
Is it a substantial burden for the maintainers to support this?
Every time when users will complain about something that sounds like a networking layer issue, it would be very important to know: is aiofastnet activate or not? So it would be good to add this question to the issue template.
aiofastnetitself is a medium size project, functionally-wise it has a limited scope, and I hope I'll be able to maintain it the next 5 years. It is relatively new, I have written a good amount of tests already and I'm currently adding more. I want to get coverage close to 100%.One important caveat is that aiofastnet currently does NOT work with uv managed python distribution.
Attempt to import aiofastnet will result in ImportError exception with such Python.
aiofastnet uses OpenSSL directly, not through stdlib ssl module. aiofastnet locates dynamically loaded
libssl.soandlibcrypto.soand get addresses of OpenSSL exported functions likeSSL_readandSSL_writeandSSL_sendfilewithdlsym. This lets aiofastnet to cut off a huge portion of python ssl plumbing.uv managed python is linked statically against all of its stdlib modules and OpenSSL, and that makes it impossible to locate OpenSSL symbols.
Currently, all ubuntu and macos tests are run with uv standalone python.
Therefore I added 2 additional test runs with python installed by
actions/setup-pythonon macos and ubuntuto make sure that all tests pass when
aiofastnetis importable.Related issue number
Checklist
CONTRIBUTORS.txt