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

Cythonize call loop #104

Closed
wants to merge 5 commits into from
Closed

Conversation

goodboy
Copy link
Contributor

@goodboy goodboy commented Nov 20, 2017

Consider this a working initial draft to begin our foray into cython-land.
The benchmark suite shows a x2 speedup with this cythonized version of _multicall 👍

@goodboy
Copy link
Contributor Author

goodboy commented Nov 20, 2017

Apparently setup_requires can be used according to this SO answer if we want to always rely on cython as a dep. Looking for opinions here.

@RonnyPfannschmidt
Copy link
Member

please dont commit the c sources to the git repo, also not exactly what i had in mind for cythonizing :(

@goodboy
Copy link
Contributor Author

goodboy commented Nov 21, 2017

please dont commit the c sources to the git repo

Done.

also not exactly what i had in mind for cythonizing :(

We can always make it better 👍.
I really just wanted to do this to see how much of a speedup we'd get.

@RonnyPfannschmidt
Copy link
Member

the biggest problem i see is we broke sane pypy support - c extensions are just not the way to go)


[testenv:benchmark]
commands=py.test {posargs:testing/benchmark.py}
commands=py.test testing/benchmark.py {posargs}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this invocation got accidentally plucked incorrectly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did this on purpose so I could pass additional args without having to pass testing/benchmark every time. Should I put it back?

@goodboy
Copy link
Contributor Author

goodboy commented Nov 21, 2017

the biggest problem i see is we broke sane pypy support - c extensions are just not the way to go)

So what did you mean by cythonize then in our previous discussions?

Also, with regard to pypy I agree it seems cython doesn't have great support although it seems the pypy build passsed?

We can keep the original pure python implementation as well and then only import the cythonized module when running on cpython?

@RonnyPfannschmidt
Copy link
Member

i recall that cython had a mode where the code was pure python * a separate file with annotation

@nicoddemus
Copy link
Member

I'm not sure the speed up is worth it; I have the feeling that the bottleneck in applications using pluggy is in the actual implementation of the hooks, not the time spent in the multi-call mechanism.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus the speed of the fixture mechanism and the hook calling mechanism is actually critical in some bits

the switch from kwargs to positional args already did a lot to safe time, and i suspect there is more to gain

i recall one of the reasons why pytest doesn't integrate xunit with fixtures is, that the fixtures where too expensive

@nicoddemus
Copy link
Member

i recall one of the reasons why pytest doesn't integrate xunit with fixtures is, that the fixtures where too expensive

Probably because the initial implementation always added a setup/teardown fixture for all levels (function/class/module) regardless if there were an implementation of setUp/tearDown in the unittest class; this could be circumvented by only creating the autouse-fixtures when there is a respective xUnit method.

But I digress, if indeed this is a bottleneck let's see if we can squeeze some more performance from it. 👍

@goodboy
Copy link
Contributor Author

goodboy commented Nov 22, 2017

i recall that cython had a mode where the code was pure python

Yes there is pure python mode though speed gains are much more negligible.
I'm happy to try this out - including the approach using the external .pxd file.

Tyler Goodlet added 5 commits January 10, 2018 11:00
Cythonize `pluggy.callers._multicall` which gives around a 2x speedup
according to the benchmark suite. Transform the `pluggy.callers`
module in a new package and move utils and the legacy call loop into
separate modules.
When cython is installed always rebuild the C sources, when
not installed use whatever C sources were included in the sdist.
@hpk42
Copy link
Contributor

hpk42 commented Oct 6, 2018

Is there any project where calling hooks is shown to be a speed issue?
I am using pluggy in 5 different projects and there is not the slightest problem.
Last time i profiled with pytest the multicall-machinery did not show up in any significant way.
So i suggest to close this issue and not bother for optimizing unless there is clear evidence it's needed (and even then, there might be easy wins without going full cython).

@goodboy
Copy link
Contributor Author

goodboy commented Oct 15, 2018

@hpk42 I totally agree. Forgive my premature cythonization ;)

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.

4 participants