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
Switch to new-style callbacks #79
Comments
Oh, interesting! Yes, let's make a branch to experiment with this in. |
Experiment branch: https://github.com/libvips/pyvips/tree/new-style-callbacks I removed the
|
Yes, I see about the same:
pillow-simd wins by a factor of two on the full pipeline, so the pillow-perf results browser should lift the vips bar by a bit more than two. Of course the same caveats apply as in the previous discussion: this is testing the speed of operations in single-threaded mode (naturally, since that's the focus of pillow-simd), not the end-to-end speed. libvips can overlap input and output (disabled in this test) and can parallelise operations (disabled in this test), so in the vips-bench benchmark, pyvips wins by x2. We should update vips-bench as well, it's been a while. |
I re-ran vips-bench with this change:
Notes:
pillow-perf and vips-bench seems to tell roughly the same story. |
I guess we should also verify that libvips in pillow-perf is hitting the vector path, and that the mask sizes pyvips and pillow-simd are using are comparable. |
.. Oh, we could try arguing for moving the transpose to the end again. It hurts libvips to have it at the start of the pipeline, and (I think?) no one uses this ordering. |
I tested, and pillow-perf does hit the libvips vector path correctly, phew! I tried adjusting the benchmark slightly:
The https://github.com/python-pillow/pillow-perf/blob/master/testsuite/cases/pillow.py#L70 I tried to get a number for the peak error by finding the max abs difference between the pillow-simd box filter and the "perfect" float gaussian in libvips -- it's 9. Perhaps RMS difference would be a better metric. It would also be better to compare to a perfect pillow gaussian. Anyway, if you adjust |
Oh, interesting, I tried on my two-core i5 laptop and with unmodified pillow-perf (ie. vips single threaded) I see:
So they are essentially the same speed. If I enable libvips threading, I see:
So libvips wins fairly easily. If I make the other changes too, ie. reorder the pipeline and enable sequential mode, I see:
I'll double-check on the big i7 machine. Shall we merge this change? It seems good to me. |
Interesting, I'll try on my Intel i5-8600K machine when I'm home. The new results on the speed and memory use wiki looks promising. It's nice to see that pyvips and lua-vips are rather close to C. I just added a small improvement to the By the way, |
Yes, I have the same results as before on the i7, so it really is an architectural thing. Perhaps pillow-simd is using AVX-512 on the desktop, and Orc is not? Anyway, I'll merge this. |
I made a PR for the URL change, but decided not to pester homm about rerunning the benchmark or reorganising the |
Sorry, I forgot, you were going to try on your desktop i5. |
On my 8th generation Intel Core i5 processor, I see (with an unmodified pillow-perf):
I've installed the AVX2-enabled version of pillow-simd with:
libvips (from commit libvips/libvips@1824c64) with:
And pyvips (API mode) from commit 1cdef97. Environment:
|
I have installed pyvips from conda-forge for osx-arm64. I get an error which I believe is related to this issue.
Please can you advise if this is possible to fix? |
pyvips only uses I'd look into what happened when you installed pyvips, and why it's (I think?) fallen back to ABI mode. |
It looks like the macOS ARM64 builds in conda-forge is cross-compiled on a macOS x86_64 host. As a result, it cannot find libvips while building the binary API extension. I noticed this in the build logs:
As a possible workaround, you can give your application the entitlement Please open a new issue at https://github.com/conda-forge/pyvips-feedstock if this continues to be a problem. |
Ok so looks like the conda installation is broken for osx-arm64. Is there any reason why I couldn't install vips via homebrew then install pyvips via pip? When I try this doesn't work out of the box as Line 19 in a6d6229
gives a |
You can check whether libvips is available and whether a sufficient version is installed with: pkg-config --exists --print-errors "vips >= 8.2" && echo OK (this is what pyvips does internally to verify if libvips is installed) If libvips is installed in a non-standard prefix, you'll need to set the export PKG_CONFIG_PATH=$(brew --prefix vips)/lib/pkgconfig:$PKG_CONFIG_PATH For checking whether the API or ABI mode is used, you can use pip install --user pyvips --verbose |
Thanks for your help. The problem was I had installed |
I think mixing conda and homebrew binaries in one process is not really supported and it likely to bite you at some point. My understanding (maybe wrong) is that you are supposed to use the conda libvips binaries with conda python. (I use homebrew for everything on macos, fwiw) |
If I do a |
See: https://cffi.readthedocs.io/en/latest/using.html#extern-python-new-style-callbacks
Occurrences of
ffi.callback
:pyvips/pyvips/gvalue.py
Line 23 in 1dc365a
pyvips/pyvips/__init__.py
Line 134 in 52e2184
pyvips/pyvips/base.py
Line 87 in 52e2184
pyvips/pyvips/voperation.py
Line 106 in 1dc365a
vips_object_get_args
for libvips 8.7+. See the lua-vips implementation)This comment can also be solved using the new style callbacks.
After this has been resolved, we should look at #21 again and benchmark it under cffi's API mode (the Pillow performance test suite still depends on an older version of pyvips which doesn't support the API mode).
The text was updated successfully, but these errors were encountered: