You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How much would the hook wrapping affect the execution time? #217
Say my application is a concurrent application and the hook implementation is applied to a great amount of data, which means it would be executed thousands of times.
So, how much is the wrapping work by pluggy affect the execution time?
I red the code and saw there is a relatively long chain from pm.hook.method() calling to the actual implementation.
Below is my summary of the calling chain:
From pm.hook.method which is actually a _HookRelay instance to
-> _HookCaller.__call__
-> PluginManager._hookexec
-> PluginManager._inner_hookexec
-> _multicall in callers.py
-> HookImpl.funcion is the actual hook implmentation
changed the title [-]How much would the hook wrapping affect the execution time of the hook implementation?[/-][+]How much would the hook wrapping affect the execution time?[/+]on May 29, 2019
Say my application is a concurrent application and the hook implementation is applied to a great amount of data, which means it would be executed thousands of times.
@nnop this is a very good question and probably a use case we could attempt to optimize for if there was a demonstrable application.
So, how much is the wrapping work by pluggy affect the execution time?
I think you've mostly figured out the call stack minus the detail that _multicall of course invokes n hook implementations (depending on what's registered at call time) and any wrappers that intercept each hook call.
In terms of minimizing the current (what, four?) extra function calls I know I've contemplated removing ._inner_hookexec since it's only used for tracing which I'm not even sure is used that much as a feature (though I'd have to let consumer project maintainers chime in).
If you want to do some further digging (and we'd appreciate the help) there's a little benchmark test suite that you can play with to try and expose bottlenecks for your use case.
Activity
[-]How much would the hook wrapping affect the execution time of the hook implementation?[/-][+]How much would the hook wrapping affect the execution time?[/+]goodboy commentedon May 29, 2019
@nnop this is a very good question and probably a use case we could attempt to optimize for if there was a demonstrable application.
I think you've mostly figured out the call stack minus the detail that
_multicallof course invokesnhook implementations (depending on what's registered at call time) and any wrappers that intercept each hook call.In terms of minimizing the current (what, four?) extra function calls I know I've contemplated removing
._inner_hookexecsince it's only used for tracing which I'm not even sure is used that much as a feature (though I'd have to let consumer project maintainers chime in).If you want to do some further digging (and we'd appreciate the help) there's a little benchmark test suite that you can play with to try and expose bottlenecks for your use case.
Hope that helps!
RonnyPfannschmidt commentedon May 29, 2019
@goodboy PYTEST_DEBUG uses tracing to sort out the call tree
goodboy commentedon May 29, 2019
@RonnyPfannschmidt gotcha, thanks.
RonnyPfannschmidt commentedon May 27, 2026
considering this answered