marbl / MetagenomeScope

Visualization tool for (meta)genome assembly graphs
https://marbl.github.io/MetagenomeScope/
GNU General Public License v3.0
24 stars 8 forks source link

Misc. viewer code optimizations #22

Open fedarko opened 6 years ago

fedarko commented 6 years ago

From @fedarko on December 28, 2016 23:22

There are a number of these things sprinkled throughout the xdot2cy.js code -- some have, e.g. O(2n) loops that could be brought down to O(n) fairly simply.

I doubt that this is causing a significant amount of bottleneck, but it'd be nice to sweep through the code and take care of this stuff at some point.

Most of these areas can be found by just searching for "TODO" (sans quotes).

Copied from original issue: fedarko/MetagenomeScope#115

fedarko commented 6 years ago

Worth taking a look at: https://googleblog.blogspot.com/2010/12/under-hood-of-google-maps-50-for.html

fedarko commented 6 years ago

consider mitigating use of eles.each() in favor of simple loops -- seems the simple loop approach is faster

fedarko commented 6 years ago

also, consider replacing usages of cy.$() or cy.filter() with code that builds collections of just the affected elements, if that's possible.

e.g. it should be possible to achieve a speedup on uses of cy.filter(":selected").unselect() by just looking at SELECTED_NODES, SELECTED_EDGES, and SELECTED_CLUSTERS and unselecting those in particular. that'd help with scaffold highlighting/etc?

fedarko commented 6 years ago

Another thing: when creating elements (nodes/edges/clusters), try to mitigate cases of unnecessarily assigning null data() values. e.g. instead of setting all nodes not in parent cluster to have parent: null, just only set the parent data field on initialization if the node in question has a parent.

this optimization probably won't do that much to help but it's something to keep in mind

fedarko commented 6 years ago

another potential thing: using a custom version of bootstrap that only supports the exact features we need? I doubt this will make any sort of significant difference on the web app's performance, but less space is always nice. (granted this would lock us out of using certain features without explicitly modifying the custom version accordingly, so it might be a good idea to hold off on that until the feature set in the viewer application sort of stabilizes eventually)

fedarko commented 6 years ago

another silly thing: I should eventually use minified versions of viewer/index.html, viewer/js/xdot2cy.js, and viewer/css/viewer_style.css for deployed versions of MetagenomeScope. Google has recommendations on resource minification here. Just from trying some of the recommended minification tools, it looks like pretty much all of these files are able to be drastically collapsed in size (by 50% or more for each -- for the JS file it's somewhere around 73%).

It shouldn't be too difficult to set up a build script which auto-minifies these files and, say, moves them to a folder of "files to upload to the demo" or something.

That being said, we should probably keep at least the first comment in the minified versions of these files (to preserve license/copyright info). Also need to test things thoroughly to ensure that nothing gets broken during this process.