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

Optimizations for SSLProtocol #626

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

tarasko
Copy link

@tarasko tarasko commented Sep 7, 2024

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

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.

1 participant