Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Agg clipping #5023

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
Sep 4, 2015
Merged

Fix Agg clipping #5023

merged 1 commit into from
Sep 4, 2015

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Sep 4, 2015

Addresses the slowness mentioned in #5016.

In the epic C++ refactor in ba40160, the line that determines whether to perform clipping of paths to the figure size in the Agg backend changed from:

    bool clip = !face.first && gc.hatchpath.isNone() && !path.has_curves();

to

    bool clip = !face.first && gc.has_hatchpath() && !path.has_curves();

Spot the problem? It means we were only clipping when there was a hatch, rather than when there wasn't a hatch -- effectively disabling it for most things.

This should have a major impact on panning and zooming performance of large time series.

I'm not exactly sure how to write a test for this -- the result, by its nature, isn't visible, and this is pretty deep into the C++ code to make a "unit test" out of it. I'll think on that some more, but in the meantime I thought it better to just address this very serious regression.

Addresses the slowness mentioned in matplotlib#5016
@mdboom mdboom added this to the next point release milestone Sep 4, 2015
@mdboom
Copy link
Member Author

mdboom commented Sep 4, 2015

I also wonder whether this addresses some of the other "extreme" slowness issues we've seen reported elsewhere.

tacaswell added a commit that referenced this pull request Sep 4, 2015
@tacaswell tacaswell merged commit b5eb974 into matplotlib:master Sep 4, 2015
@tacaswell
Copy link
Member

This didn't fix it completely for me either

(dd_py3k) ✔ /tmp 
00:59 $ time python slow.py 7 100 
ascending x sequence

real    0m1.969s
user    0m1.590s
sys     0m0.367s

(dd_py3k) ✔ /tmp 
00:59 $ time python slow.py 7 100 reversed
descending x sequence

real    0m2.375s
user    0m1.927s
sys     0m0.443s

But made way better so merged.

[edited as my first benchmark attempt included re-building the font cache]

@efiring
Copy link
Member

efiring commented Sep 4, 2015

I think that is the best one can expect; the patch fixed the regression completely. The user time is longer for the reversed case because it is not getting the benefit of subslicing. The sys time variation is random.
It would be possible to make subslicing work for the reversed case, but I think the difference is small enough and the occurrence of use cases with descending x is rare enough that it is just as well to leave that change out.

@mdboom mdboom deleted the fix-clipping branch November 10, 2015 02:46
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.

3 participants