-
Notifications
You must be signed in to change notification settings - Fork 124
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
Improve subset hook caller & related changes #348
Conversation
1f0f1fa
to
8c6aa03
Compare
I'll look into the missing coverage later. |
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.
creative approach, i like it as a nice intermediate
@@ -453,6 +451,53 @@ def _maybe_apply_history(self, method: "HookImpl") -> None: | |||
result_callback(res[0]) | |||
|
|||
|
|||
class _SubsetHookCaller(_HookCaller): |
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.
in a follow-up we might want to introduce a hook caller protocol as part of the exposed type cleanup
at a later point in time i would like to make pluggy able to work with a dependency topology of plugins
(to better serparae conftests and eventually allow a dependency tree of plugins)
but thats for 2023 or later
The hookexec receives them in a single list (which is good), so make the HookCaller keep them in a single array as well, so can avoid the list concatenation in the hot call path. This makes adding a hookimpl a little slower, but not by much, and it is much colder than calling so the tradeoff makes sense. It is possible to optimize by keeping track of the splitpoint instead of calculating it every time, but I don't think it's worth it.
…dalone HookCaller Fix pytest-dev#346. Fix pytest-dev#347.
We can do everything necessary with just the `_name2plugin` dict; while it makes some operations slower (registration and unregistration), they are not in any hot path (calling) so not a problem.
8c6aa03
to
12ea858
Compare
I increased the coverage some (and fixed a bug - I also tested performance with pytest. Admittedly not very extensively (we really need a proper pytest benchmark) but I checked pytest itself, pandas and some small projects, and not much affect, just a very slight improvement. So I think it's good to go. |
Note: I forgot about changelogs. At this point I'll probably add them before the next release. |
This PR contains 3 changes, which are (mostly) conceptually independent but better understood together.
The second commit fixes #346 and #347. The idea is, instead of creating a full-fledged HookCaller, create one which just proxies to the real HookCaller + the plugin filtering. The implementation is a bit hacky but the best I could come up after trying several approaches.
I ran the pytest testsuite and everything passes (after pytest-dev/pytest#9512).
pluggy's benchmark suite looks good (not much difference, maybe a slight improvement). I still need to check pytest though, as pluggy's benchmark doesn't cover
subset_hook_caller
at all.Please see the commits for details.