Faster flexdashboard loading

Hi all,

I am working on an rmarkdown file that makes use of flexdashboard and shiny. I have to load in quite a few large .csv files and in general the starting up of the application is very slow.
I ready about the "global" chunk and applied this to my rmarkdown file. I also made sure to install the latest version of rmarkdown beforehand since the global chunk is new since version 1.1.
I moved the loading of my data into the global chunk, but nothing has changed in the startup time.
Previously I have used the profvis package on a shiny app to see where my performance issues were coming from, but in this case I am not sure about what I could do to investigate the issue.

The file I am working on is a commercial product of my company and so it is vital for us to improve performance in order to satisfy customer needs. I am aware that eventually, we might run into limitations when using flexdashboard and may have to use a full shiny app, but nonetheless I would like to know which options I have at the moment and how I can investigate where potential bottlenecks are.

All help is much appreciated!

Does the profvis output suggest that most of the start-up time is spent reading your csvs? If so, what are you using to read those csvs? There are a number of different things you can do to try and speed up the data loading step (including using a different file format). This article has a nice overview and benchmark of popular options, but also check out the new vroom package

Thank you for your reply and suggestions.

We are using read.csv().
I have not used profvis with this application because it is an .rmd file. I am not sure how to use it, but if there are instructions somewhere, I would be very happy to give it a try.

Any ideas on why the global chunk is not leading to any noticeable changes in performance?

You can use profvis with an Rmd file in the following way:

profvis::profvis(expr = rmarkdown::run("flexdashboard.Rmd"), prof_output = "flexdashboard.html")

Also, from my understanding, the objects defined in global chunk are visible across all session. This is great for loading data in a hosted document (will load it once for one user and make it available to every other user). However, if you're running this in your local computer, it'll still need to load all the data every time you render the document.

1 Like

Adding to @jdb comment, global will only lead to performance gains when multiple users are visiting the same app.

1 Like

Thank you to the both of you; this is super helpful.
I will give profiling a try and will look into file loading alternatives should this be the root of the problem.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.