Skip to content
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

Increase rendering performance #78

Merged
merged 7 commits into from
Aug 24, 2022
Merged

Increase rendering performance #78

merged 7 commits into from
Aug 24, 2022

Conversation

quantumjot
Copy link
Collaborator

@quantumjot quantumjot commented Jun 27, 2022

I did some profiling of the rendering code using examples/show_large_tree.py and 255 nodes (depth 8):

255 total nodes
         7509808 function calls (7448213 primitive calls) in 4.881 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.001    0.001    4.881    4.881 base_plotter.py:50(draw_from_nodes)
      892    0.005    0.000    4.370    0.005 visuals.py:125(__init__)
      509    0.002    0.000    2.784    0.005 vispy_plotter.py:110(add_branch)
      892    0.004    0.000    2.626    0.003 visual.py:325(__init__)
      509    0.004    0.000    2.552    0.005 vispy_plotter.py:156(add_track)

It looks like a lot of the time is in adding subvisuals, so I had a go at setting things up with a single subvisual for all branches. This gets the performance to a much better state:

255 total nodes
         121140 function calls (119670 primitive calls) in 0.138 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.140    0.140 base_plotter.py:50(draw_from_nodes)
      509    0.001    0.000    0.100    0.000 vispy_plotter.py:110(add_branch)
      509    0.006    0.000    0.086    0.000 vispy_plotter.py:88(autoscale_view)
6777/6009    0.023    0.000    0.046    0.000 {built-in method numpy.core._multiarray_umath.implement_array_function}
        1    0.009    0.009    0.036    0.036 tree.py:35(layout_tree)

0.14 seconds versus 4.88 seconds. We will probably want to look at the graph searching algorithms at some point, but this is a good start.

This also merges the small changes in #77, so I will close that one.

napari-arboretum

@deprecated-napari-hub-preview-bot
Copy link

deprecated-napari-hub-preview-bot bot commented Jun 27, 2022

Preview page for your plugin is ready here:
https://preview.napari-hub.org/lowe-lab-ucl/arboretum/78
Updated: 2022-07-01T15:38:27.392683

@KristinaUlicna
Copy link
Contributor

Just checked the performance on some larger trees, it works great! 🚀

@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2022

Codecov Report

Merging #78 (7e21492) into main (bb23b25) will decrease coverage by 2.98%.
The diff coverage is 96.20%.

@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
- Coverage   96.28%   93.30%   -2.99%     
==========================================
  Files          16       16              
  Lines         538      612      +74     
==========================================
+ Hits          518      571      +53     
- Misses         20       41      +21     
Impacted Files Coverage Δ
napari_arboretum/visualisation/base_plotter.py 91.86% <75.00%> (-0.83%) ⬇️
napari_arboretum/visualisation/vispy_plotter.py 85.13% <97.10%> (-12.40%) ⬇️
napari_arboretum/plugin.py 89.06% <100.00%> (ø)
napari_arboretum/tree.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb23b25...7e21492. Read the comment docs.

@quantumjot quantumjot linked an issue Jul 1, 2022 that may be closed by this pull request
@KristinaUlicna
Copy link
Contributor

Looks great! :) All trees show, the single-branch tracks are centred and the performance seems to be better than before (didn't run into the kernel crashing yet). But in the meantime, we lost the y-axis next to the tree [as in #46].

@quantumjot quantumjot marked this pull request as ready for review August 24, 2022 12:09
@quantumjot quantumjot merged commit f2eec96 into main Aug 24, 2022
@quantumjot quantumjot deleted the increase-performance branch September 13, 2022 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants