uvloop
uvloop copied to clipboard
Improve SSL performance by calling SSLProtocol methods directly, not through the python's vectorcall interface
After profiling my app with perf I identified a couple of things that make SSLProtocol a little bit faster:
- SSLProtocol.get_buffer and buffer_updated can be called directly from UVStream since it is our own type and we know it's definition
- Added inline directive to all private methods of SSLProtocol to avoid vtable calls
Before:
--42.75%--__pyx_f_6uvloop_4loop___uv_stream_buffered_on_read
|
--42.19%--__pyx_f_6uvloop_4loop_run_in_context1
|
--41.92%--cfunction_vectorcall_FASTCALL_KEYWORDS
context_run
|
--41.83%--_PyObject_VectorcallTstate.lto_priv.18
|
--41.73%--method_vectorcall
|
--41.32%--__pyx_pw_6uvloop_4loop_11SSLProtocol_15buffer_updated
--2.51%--__pyx_f_6uvloop_4loop___uv_stream_buffered_alloc
|
--1.40%--__pyx_f_6uvloop_4loop_run_in_context1
|
--0.67%--cfunction_vectorcall_FASTCALL_KEYWORDS
context_run
After:
--43.18%--__pyx_f_6uvloop_4loop___uv_stream_buffered_on_read
|
--42.57%--__pyx_f_6uvloop_4loop_11SSLProtocol_buffer_updated_impl
--0.79%--__pyx_f_6uvloop_4loop___uv_stream_buffered_alloc
|
--0.60%--PyGILState_Ensure