Open etowahadams opened 9 months ago
Spec:
{"layout": "linear","arrangement": "vertical","centerRadius": 0.8,"xDomain": {"chromosome": "chr1", "interval": [1, 3000500]},"views": [{"tracks": [{"id": "track-6","data": {"url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec","type": "multivec","row": "sample","column": "position","value": "peak","categories": ["sample 1", "sample 2", "sample 3", "sample 4"]},"mark": "point","x": {"field": "position", "type": "genomic", "axis": "top"},"y": {"field": "peak", "type": "quantitative", "grid": true},"size": {"field": "peak", "type": "quantitative"},"color": {"field": "sample", "type": "nominal", "legend": true},"opacity": {"value": 0.5},"tooltip": [{"field": "start", "type": "genomic", "alt": "Start Position"},{"field": "end", "type": "genomic", "alt": "End Position"},{"field": "peak","type": "quantitative","alt": "Value","format": ".2"},{"field": "sample", "type": "nominal", "alt": "Sample"}],"width": 600,"height": 130}]}]}
Before: 5.5 ms to draw a frame
After: 1.3 ms to draw, or a 4.2X speedup
After
Changes:
encodedPIXIvalues
is expensive -> instead look up once and cache the results in GoslingTrackModelTheoretically, it should take 1.3 ms to draw each track. Does draw time scale linearly with the number of tracks? Yes, but not with the relation that we want. Specifically, it draws 2x-1 times more than it needs to.
For example, here a visualization with 3 tracks. We expect each track to be drawn only once (3 total calls to draw) but instead we see 5.
Overall, this amounts in the following relationship:
The frame-rate of certain Gosling visualizations is very low when zooming and panning. What are the main bottlenecks?
Flame charts
We can interact with laggy visualzations and observe their flame charts to understand what is causing poor performance.
Multiple Sequence Alignment
Here's a flame graph when zooming in and out of :
SARS-Cov2
Corces et al.
Mark Displacement
Observations
Based on the flame charts, we observe three main bottlenecks:
Reduce redrawing
Redrawing everything to the same Graphics object is expensive. There are several strategies to overcome this
Initialize GoslingTrackModel only when needed
GoslingTrackModels are reinitialized every time
draw()
is called. However, it only changes when the data, spec, or theme changes. We need to persist the models unless the data, spec, or theme changes.