PERF: Defer tick materialization during Axes init/clear#31525
PERF: Defer tick materialization during Axes init/clear#31525eendebakpt wants to merge 9 commits intomatplotlib:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5708dc8 to
3ac8224
Compare
timhoffm
left a comment
There was a problem hiding this comment.
Thanks for the PR. The speedup is impressive, and the added complexity (rc caching) is bearable.
Strategically, I would like to move away from single-tick handling, but in the mean time this is a reasonable improvement.
Having tick collections is indeed the way to go. This change is orthogonal as it avoids some tick operations altogether. (but maybe if ticks are really fast that would not matter) |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
a3f1be1 to
d0ed04c
Compare
timhoffm
left a comment
There was a problem hiding this comment.
Thanks, this is a substantial and concise improvement now!
Thanks for reviews! This was (and still is) tricky to get right. If you have more suggestions (in particular for additional tests) let me know |
PR summary
The performance if matplotlibs ticks is a bottleneck in various plots. See for example the discussions and references in #5665, #31012, #29594.
In this PR we prevent materialization of the
_LazyTickListwhen there are no ticks created yet. With the tick-materialization cascade gone from Axes.__clear, the spine transforms the cascade used to install as a side effect are installed explicitly at the end of __clear.Benchmark results (updated):
Benchmark script
Closes #23771.
AI Disclosure
Claude was used in identifying performance bottlenecks related to tick creation. Initially the goal was to create tick collections (as described in one of the references), but this approach seems to be a small change with large impact.
PR checklist