-
Notifications
You must be signed in to change notification settings - Fork 601
Improve SSL performance by calling SSLProtocol methods directly, not through the python's vectorcall interface #626
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
base: master
Are you sure you want to change the base?
Conversation
04ec4d5 to
afe7e60
Compare
fantix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement!
uvloop/handles/stream.pyx
Outdated
|
|
||
| # Fast pass for our own SSLProtocol | ||
| # avoid python calls, memoryviews, context enter/exit, etc | ||
| if isinstance(sc._protocol, SSLProtocol): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isinstance is cheap, but maybe we can repurpose UVStream._buffered to an integer enum of 3 values:
0for non-buffered protocol1for general buffered protocol2for uvloop SSLProtocol
So that we can replace such isinstance calls with even cheaper int check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
After profiling my app with perf I identified a couple of things that make SSLProtocol a little bit faster:
Before:
After: