Title: Tick rendering speedups by scottshambaugh · Pull Request #29394 · matplotlib/matplotlib · GitHub
Open Graph Title: Tick rendering speedups by scottshambaugh · Pull Request #29394 · matplotlib/matplotlib
X Title: Tick rendering speedups by scottshambaugh · Pull Request #29394 · matplotlib/matplotlib
Description: PR summary I'm starting an effort to speed up 3D rendering, spinning up a profiler on some test cases. For this MR, I'm focusing on draw speed for an empty plot. Based on py-spy profiling, the largest proportion of render time is dedicated to handling tick marks. This PR implements several optimizations to speed up tick drawing. Based on averaging 6x runs of the below script that executes 100x draw calls, the average render time for the basic empty plot decreased from 23.1 ms to 19.1 ms, which is a 21% improvement. Qualitatively, rotating the plot definitely feels snappier on my machine. import matplotlib.pyplot as plt import time fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.view_init(0, 0, 0) plt.show(block=False) plt.pause(1) # Start timing start_time = time.perf_counter() n = 100 pause_time = 0.1 for i in range(n): ax.view_init(0, 0, i*10) plt.draw() plt.pause(pause_time) # End timing end_time = time.perf_counter() # Calculate actual computation time by subtracting pauses total_pause_time = n * pause_time computation_time = (end_time - start_time) - total_pause_time print(f"Total time: {end_time - start_time:.4f} seconds") print(f"Computation time (excluding pauses): {computation_time:.4f} seconds") print(f"Average time per loop: {computation_time / n * 1000:.2f} ms") Attached are representative before and after profiler runs, which can be uploaded to https://www.speedscope.app/ to view profile_ticks_speedups.speedscope.json profile_ticks_base.speedscope.json PR checklist [n/a] "closes #0000" is in the body of the PR description to link the related issue new and changed code is tested [n/a] Plotting related features are demonstrated in an example [n/a] New Features and API Changes are noted with a directive and release note [n/a] Documentation complies with general and docstring guidelines
Open Graph Description: PR summary I'm starting an effort to speed up 3D rendering, spinning up a profiler on some test cases. For this MR, I'm focusing on draw speed for an empty plot. Based on py-spy profiling, ...
X Description: PR summary I'm starting an effort to speed up 3D rendering, spinning up a profiler on some test cases. For this MR, I'm focusing on draw speed for an empty plot. Based on py-spy pro...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/29394
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b3358e84-e5b3-b5dc-4cee-cee98435e914 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 83F6:13D32C:339EC7:45C373:6A51BE80 |
| html-safe-nonce | ac1f6077c20e93014a4c085135440e080d98afec54171fa0b994d8acd4b56353 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0Y2OjEzRDMyQzozMzlFQzc6NDVDMzczOjZBNTFCRTgwIiwidmlzaXRvcl9pZCI6IjYyODkzNjc0NjY1NjE4Nzk2ODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ae21441cdb2d1a7942bca5227189b50bab6886198d5befd559c18edc659bd04a |
| hovercard-subject-tag | pull_request:2256812267 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/29394/files |
| twitter:image | https://avatars.githubusercontent.com/u/14363975?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/14363975?s=400&v=4 |
| og:image:alt | PR summary I'm starting an effort to speed up 3D rendering, spinning up a profiler on some test cases. For this MR, I'm focusing on draw speed for an empty plot. Based on py-spy profiling, ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width