当前位置: 动力学知识库 > 问答 > 编程问答 >

r - Slowness and GC when launching shiny application

问题描述:

I have an issue when running R scripts through shiny versus out of shiny.

Here is what I do:

1/ load a data.table saved on disk (around 2 millions lines)

2/ filter the data.table based on some values of the columns

3/ plot an histogram via ggplot2

When I do this in a R script, it takes only a few seconds. But when I run the same thing in shiny (loading data in global.R and using a reactive to filter data), it takes minutes. And it seems (profvis) that most of the time is spent in GC, eventhough there is more than enough memory on the desktop.

Here is the sessionInfo:

sessionInfo()

R version 3.2.2 (2015-08-14)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 15.10

locale:

[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8 LC_MONETARY=fr_FR.UTF-8

[6] LC_MESSAGES=fr_FR.UTF-8 LC_PAPER=fr_FR.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C

[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C

attached base packages:

[1] stats graphics grDevices utils datasets methods base

other attached packages:

[1] data.table_1.9.6 googleVis_0.5.10 plotly_2.0.16 ggplot2_2.0.0 lubridate_1.5.0 stringr_1.0.0 plyr_1.8.3

loaded via a namespace (and not attached):

[1] Rcpp_0.12.3 digest_0.6.9 chron_2.3-47 grid_3.2.2 R6_2.1.1 jsonlite_0.9.19 gtable_0.1.2 magrittr_1.5

[9] scales_0.3.0 httr_1.0.0 stringi_1.0-1 viridis_0.3.2 RJSONIO_1.3-0 tools_3.2.2 htmlwidgets_0.5 munsell_0.4.2

[17] base64enc_0.1-3 colorspace_1.2-6 htmltools_0.3 gridExtra_2.0.0

Do you know how I could investigate to avoid slowing down R when launched through shiny?

I have tried to launch the application via Rstudio, a R session or a shiny server: I always have this slowness issue, so now I do not know what I can test to make it work correctly.

Do you have any idea of what I could do to fix my issue?

Any help will be appreciated.

Regards

分享给朋友:
您可能感兴趣的文章:
随机阅读: