Shiny Lag Issue, Too Many Reactives?

679 views
Skip to first unread message

Mike C

unread,
Aug 7, 2013, 2:48:56 PM8/7/13
to shiny-...@googlegroups.com
Hey all,

I have been trying to make my app run more efficiently- because to my surprise, it can be a bit lagged on my 10gb mac desktop.  I investigated the memory usage on the machine after restarting, as the program ran and looked to see when it became sluggish responding to the user input.  I did not notice it ever having issues with ram, it almost always had at least 7gb free to work with, regardless of how sluggish it was/wasn't.

I then decided to see which tabs it became sluggish after completing- I should probably describe the overall structure of my app.  The app is initially divided into many 6 tabs, all of which are page with sidebars.  The first tab is a initiation tab, where all the options are set for the analysis ahead, and after filling in all the fields, the analysis is run.  The five additional tabs are to generate and view figures and tables from the results of the analysis run on the first tab.  In the first tab, one of the fields is a 'select columns', not dissimilar from Winston's example.  This is the area in which I test the lag of checkbox clicking, initially, it is very rapid and keeps up with how fast I can click the buttons.

The first tab has ~10 inputs, which are put into reactives and isolated by one of several action buttons.  After running the analysis itself, the checkboxes are only slightly more lagged, barely noticeable.
The second tab generates a simple plot, and there are only 3 inputs, which are put into reactives and isolated with an action button.  after generating a plot, there is no noticeable difference from the prior step.
The third tab and the fourth tab are similar, in that they have ~10 inputs each, which are turned into isolated reactives, and generate a plot and a table, respectively.  It is after generating either of these that the app becomes slow to respond to user input. 
The fifth tab itself has only 2 inputs, each turned into an isolated reactive, but has 5 tabs, each of which have 3 tables.  There was no lag after generating these tables.
The sixth tab generates between 2 and 40 plots, but it is an optional analysis which takes a while to run, so I haven't tested it yet.

So my question is, has anyone else experienced shiny being slow to respond to your input after generating ~20-30 reactives?  Or do you think it may be something else?

Thanks again,
Mike

Joe Cheng

unread,
Aug 8, 2013, 3:46:51 PM8/8/13
to shiny-...@googlegroups.com
It's unlikely the number of reactives would slow things down--the overhead of reactive execution is fairly low and cost no CPU when they are not invalidated.

Would it be possible to share your code?
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Sent from my phone

Mike C

unread,
Aug 9, 2013, 10:04:02 AM8/9/13
to shiny-...@googlegroups.com
Sure, I'll upload it to a dropbox and email you the think, my boss has asked that I request that the data/code not be passed along beyond you, though. 

Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joe Cheng

unread,
Aug 11, 2013, 11:21:01 AM8/11/13
to shiny-...@googlegroups.com
It's unlikely the number of reactives would slow things down--the overhead of reactive execution is fairly low and cost no CPU when they are not invalidated.

Would it be possible to share your code?

On Wednesday, August 7, 2013, Mike C wrote:
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mike C

unread,
Aug 12, 2013, 9:08:12 AM8/12/13
to shiny-...@googlegroups.com
did the dropbox link not find the right home, to your @rstudio.com address?
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mike C

unread,
Aug 16, 2013, 2:09:58 PM8/16/13
to shiny-...@googlegroups.com
Well, a surprisingly decent solution popped up, sprinkling gc() liberally throughout the code (just not the last line of the reactives and such), seems to have helped a lot.  I guess it can be chalked mostly up to R itself.

Mike C

unread,
Aug 19, 2013, 1:29:19 PM8/19/13
to shiny-...@googlegroups.com
My problem was found- it isn't too many reactives, or even large amounts of data stored in reactives- it is the use of several conditional panels.  I had it set up so that there were 2 input fields (generated with renderUI, unsure if this is relevant) within each conditional panel.  I had two pages with a similar setup, I removed the conditional panel aspect from one (making their input fields always on display), and left the other as-is.  The lag only occurred after viewing the unchanged page with conditional panels in tact, the page without the conditional panels did not result in any issues.  I removed the conditional panels from both pages, and the lag is completely gone.  FWIW if you find that it takes a bit too long for your button clicks to respond, check if you have conditional panels on the page.

Joe Cheng

unread,
Aug 20, 2013, 12:44:08 AM8/20/13
to shiny-...@googlegroups.com
Very strange! Thanks for the update.

We hope to add tools to Shiny soon, to make this kind of thing much easier to track down.


To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages