Skip to content

cairo: remove the append_path() fast path #13042

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

Merged
merged 1 commit into from
Dec 29, 2018

Conversation

lazka
Copy link
Contributor

@lazka lazka commented Dec 23, 2018

PR Summary

With the performance improvements in #13039 the old slow path is now faster
than the previously fast one. And it also works with pycairo.

Using the Gtk3Cairo backend with wire3d_animation_sgskip.py:

cairocffi + append_fast: 13.27 fps
cairo + append_slow: 15.07 fps
cairocffi + append_slow: 13.54 fps

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@timhoffm
Copy link
Member

Should be discussed after #13039 and #13040.

With the performance improvements in matplotlib#13039 the old slow path is now faster
than the previously fast one. And it also works with pycairo.

Using the Gtk3Cairo backend with wire3d_animation_sgskip.py:

cairocffi + append_fast: 13.27 fps
cairo + append_slow: 15.07 fps
cairocffi + append_slow: 13.54 fps
@lazka lazka force-pushed the cairo-remove-fast-path branch from bc6bd9b to d6ce849 Compare December 25, 2018 10:01
@lazka
Copy link
Contributor Author

lazka commented Dec 25, 2018

This should be ready now.

@tacaswell tacaswell added this to the v3.1 milestone Dec 25, 2018
@tacaswell tacaswell requested a review from anntzer December 25, 2018 16:53
@tacaswell
Copy link
Member

I would like @anntzer to take a look at this before we merge, I suspect this orthogonal to mplcairo, but just want to be sure.

@anntzer
Copy link
Contributor

anntzer commented Dec 29, 2018

I was thinking that for very long paths (e.g. plot(np.random.rand(10000))), the "fast" codepath would still be preferable (as it converts the whole Path object to cairo's internal representation in one go, rather than looping on Python's side), but interestingly this is not the case.
I thought what's happening is that:

  • for short paths, @lazka's optimizations made python-side iteration fast enough that the previously slow path is good enough,
  • for long paths, when rasterizing to the screen or to png, it's the rasterization time itself that starts dominating over the loop-in-python (because the rasterizer must check for all possible self-intersections of the path).
    However, the "slow" codepath is actually also faster when writing to a vector format (e.g. pdf), so that can't be the only explanation involved.

In any case, I can repro the reasonable performance (and yes this is totally orthogonal to mplcairo, thanks for the heads up).

@anntzer anntzer merged commit ae5945f into matplotlib:master Dec 29, 2018
@lazka
Copy link
Contributor Author

lazka commented Dec 29, 2018

Thanks! :)

lazka added a commit to lazka/matplotlib that referenced this pull request Dec 31, 2018
As seen in matplotlib#13042 it's a bit faster than cairocffi and it also takes 50 ms less
time to import here. Also the GTK3Cairo backend requires pycairo, so there is a
good chance it's already loaded anyway for that case.
lazka added a commit to lazka/matplotlib that referenced this pull request Dec 31, 2018
As seen in matplotlib#13042 it's a bit faster than cairocffi and it also takes 50 ms less
time to import here. Also the GTK3Cairo backend requires pycairo, so there is a
good chance it's already loaded anyway for that case.
lazka added a commit to lazka/matplotlib that referenced this pull request Dec 31, 2018
As seen in matplotlib#13042 it's a bit faster than cairocffi and it also takes 50 ms less
time to import here. Also the GTK3Cairo backend requires pycairo, so there is a
good chance it's already loaded anyway for that case.
@lazka lazka mentioned this pull request Dec 31, 2018
6 tasks
lazka added a commit to lazka/matplotlib that referenced this pull request Dec 31, 2018
As seen in matplotlib#13042 it's a bit faster than cairocffi and it also takes 50 ms less
time to import here. Also the GTK3Cairo backend requires pycairo, so there is a
good chance it's already loaded anyway for that case.
lazka added a commit to lazka/matplotlib that referenced this pull request Jan 6, 2019
As seen in matplotlib#13042 it's a bit faster than cairocffi and it also takes 50 ms less
time to import here. Also the GTK3Cairo backend requires pycairo, so there is a
good chance it's already loaded anyway for that case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants