leylabdotorg / amlviz

1 stars 3 forks source link

Figure out performance bottlenecks #43

Closed chrisamiller closed 11 months ago

chrisamiller commented 1 year ago

Server is often slow to load plots. (select your options, wait 5-10s for one to appear). Where is the bottleneck?

See if we can get a handle on what the biggest slowdown is. Could use a fancy profiling package, but honestly, some print statements with timestamps would probably get you there much faster.

Once we know what the bottleneck is, we can talk through the right approach to speeding things up

paytonredemer commented 1 year ago

Querying the db takes a second or two for a very large query. With that in mind, we should probably try to "cache" more.

One place that I know really slows things down is selecting and unselecting options. Currently, a new query is sent each time an option is changed. So if you change three options, then three queries are sent. Also, the request for each query blocks the application, so you have to wait for each query to finish. This is especially frustrating for users who select and unselect options very quickly.

For example, if you were where to select 3 options, then the application would do this:

SELECT Expression FROM table WHERE Gene=Desired_Gene AND (FAB='M1')
SELECT Expression FROM table WHERE Gene=Desired_Gene AND (FAB='M1' OR FAB='M2')
SELECT Expression FROM table WHERE Gene=Desired_Gene AND (FAB='M1' OR FAB='M2' OR FAB='M3')

It would make more sense to just query for the gene and then filter options on the R side. That way we're not querying the db so much.

chrisamiller commented 11 months ago

improved in https://github.com/leylabdotorg/amlviz/pull/46