RStudio: Long Startup Time (> 30 seconds)

Hi there,

I am experience quite long startup times using RStudio. This topic might be related to Rstudio Startup time ~40 seconds, but I thought I open a new thread as the R profiling results are different. If I should rather post it in the existing thread, please let me know.

So far I have run the profiling described in the old post:

It's possible some of the slowness is caused by R code that RStudio is running behind the scenes. Can you try running an R profile? Try the following:

Within R, execute:

file.edit("~/.Rprofile")

to edit your global .Rprofile. In that file, try adding:

Rprof("~/rstudio-trace.Rprof")

After doing this, close RStudio, then re-launch it. After RStudio has successfully launched, run:

Rprof(NULL)

Then, find the file at "~/rstudio-trace.Rprof", and share it with us.

You can also try sharing the printed output of

summaryRprof("~/rstudio-trace.Rprof")

directly, as that may point us towards what we need to know.

This yields to this output from utils::summaryRprof("~/rstudio-trace.Rprof"):

$by.self
                   self.time self.pct total.time total.pct
"system2"              30.42    98.70      30.42     98.70
"file"                  0.06     0.19       0.06      0.19
"lazyLoadDBfetch"       0.06     0.19       0.06      0.19
"c"                     0.04     0.13       0.04      0.13
"gsub"                  0.04     0.13       0.04      0.13
"getInlineInfo"         0.02     0.06       0.04      0.13
"base::list.dirs"       0.02     0.06       0.02      0.06
"close.connection"      0.02     0.06       0.02      0.06
"file.exists"           0.02     0.06       0.02      0.06
"findCenvVar"           0.02     0.06       0.02      0.06
"fsub"                  0.02     0.06       0.02      0.06
"ls"                    0.02     0.06       0.02      0.06
"mode"                  0.02     0.06       0.02      0.06
"saveRDS"               0.02     0.06       0.02      0.06
"unlink"                0.02     0.06       0.02      0.06

$by.total
                                       total.time total.pct self.time self.pct
"tryCatch"                                  30.74     99.74      0.00     0.00
"tryCatchList"                              30.74     99.74      0.00     0.00
".rs.executeFunctionInChildProcess"         30.46     98.83      0.00     0.00
".rs.inferReticulatePython"                 30.46     98.83      0.00     0.00
"system2"                                   30.42     98.70     30.42    98.70
"doTryCatch"                                 0.28      0.91      0.00     0.00
"tryCatchOne"                                0.28      0.91      0.00     0.00
"base::try"                                  0.12      0.39      0.00     0.00
"withCallingHandlers"                        0.10      0.32      0.00     0.00
".rs.rpc.get_completions"                    0.08      0.26      0.00     0.00
"<Anonymous>"                                0.08      0.26      0.00     0.00
"eval"                                       0.08      0.26      0.00     0.00
"eval.parent"                                0.08      0.26      0.00     0.00
"local"                                      0.08      0.26      0.00     0.00
"source"                                     0.08      0.26      0.00     0.00
"try"                                        0.08      0.26      0.00     0.00
"file"                                       0.06      0.19      0.06     0.19
"lazyLoadDBfetch"                            0.06      0.19      0.06     0.19
"addParaBreaks"                              0.06      0.19      0.00     0.00
"cmp"                                        0.06      0.19      0.00     0.00
"cmpCall"                                    0.06      0.19      0.00     0.00
"cmpfun"                                     0.06      0.19      0.00     0.00
"compiler:::tryCmpfun"                       0.06      0.19      0.00     0.00
"FUN"                                        0.06      0.19      0.00     0.00
"genCode"                                    0.06      0.19      0.00     0.00
"h"                                          0.06      0.19      0.00     0.00
"htmlify"                                    0.06      0.19      0.00     0.00
"isBlankLineRd"                              0.06      0.19      0.00     0.00
"lapply"                                     0.06      0.19      0.00     0.00
"of1"                                        0.06      0.19      0.00     0.00
"Rd2HTML"                                    0.06      0.19      0.00     0.00
"tryInline"                                  0.06      0.19      0.00     0.00
"utils:::getSrcByte"                         0.06      0.19      0.00     0.00
"writeBlock"                                 0.06      0.19      0.00     0.00
"writeContent"                               0.06      0.19      0.00     0.00
"writeLines"                                 0.06      0.19      0.00     0.00
"writeLinesUTF8"                             0.06      0.19      0.00     0.00
"writeSection"                               0.06      0.19      0.00     0.00
"c"                                          0.04      0.13      0.04     0.13
"gsub"                                       0.04      0.13      0.04     0.13
"getInlineInfo"                              0.04      0.13      0.02     0.06
".rs.appendCompletions"                      0.04      0.13      0.00     0.00
".rs.appendCompletionsOptionalElement"       0.04      0.13      0.00     0.00
".rs.getCompletionsFunction"                 0.04      0.13      0.00     0.00
".rs.getRCompletions"                        0.04      0.13      0.00     0.00
".rs.packages.initialize"                    0.04      0.13      0.00     0.00
".rs.updatePackageEvents"                    0.04      0.13      0.00     0.00
"cmpBuiltinArgs"                             0.04      0.13      0.00     0.00
"loadNamespace"                              0.04      0.13      0.00     0.00
"psub"                                       0.04      0.13      0.00     0.00
"base::list.dirs"                            0.02      0.06      0.02     0.06
"close.connection"                           0.02      0.06      0.02     0.06
"file.exists"                                0.02      0.06      0.02     0.06
"findCenvVar"                                0.02      0.06      0.02     0.06
"fsub"                                       0.02      0.06      0.02     0.06
"ls"                                         0.02      0.06      0.02     0.06
"mode"                                       0.02      0.06      0.02     0.06
"saveRDS"                                    0.02      0.06      0.02     0.06
"unlink"                                     0.02      0.06      0.02     0.06
".First.sys"                                 0.02      0.06      0.00     0.00
".rs.emptyCompletions"                       0.02      0.06      0.00     0.00
".rs.getAnywhere"                            0.02      0.06      0.00     0.00
".rs.getCompletionsArgument"                 0.02      0.06      0.00     0.00
".rs.getCompletionsSearchPath"               0.02      0.06      0.00     0.00
".rs.httpdPort"                              0.02      0.06      0.00     0.00
".rs.httpdPortIsFunction"                    0.02      0.06      0.00     0.00
".rs.initHelp"                               0.02      0.06      0.00     0.00
".rs.makeCompletions"                        0.02      0.06      0.00     0.00
".rs.matchCall"                              0.02      0.06      0.00     0.00
".rs.objectsOnSearchPath"                    0.02      0.06      0.00     0.00
".rs.setVar"                                 0.02      0.06      0.00     0.00
".rs.tutorial.findTutorials"                 0.02      0.06      0.00     0.00
"append"                                     0.02      0.06      0.00     0.00
"cb$putcode"                                 0.02      0.06      0.00     0.00
"cb$putconst"                                0.02      0.06      0.00     0.00
"close"                                      0.02      0.06      0.00     0.00
"cmpBuiltin"                                 0.02      0.06      0.00     0.00
"cmpCallArgs"                                0.02      0.06      0.00     0.00
"cmpCallSymFun"                              0.02      0.06      0.00     0.00
"cmpDotInternalCall"                         0.02      0.06      0.00     0.00
"cmpSym"                                     0.02      0.06      0.00     0.00
"cmpWhileBody"                               0.02      0.06      0.00     0.00
"get"                                        0.02      0.06      0.00     0.00
"getNamespace"                               0.02      0.06      0.00     0.00
"library"                                    0.02      0.06      0.00     0.00
"readLines"                                  0.02      0.06      0.00     0.00
"Reduce"                                     0.02      0.06      0.00     0.00
"registerS3methods"                          0.02      0.06      0.00     0.00
"require"                                    0.02      0.06      0.00     0.00
"runHook"                                    0.02      0.06      0.00     0.00
"sapply"                                     0.02      0.06      0.00     0.00
"suppressWarnings"                           0.02      0.06      0.00     0.00
"system.file"                                0.02      0.06      0.00     0.00

$sample.interval
[1] 0.02

$sampling.time
[1] 30.82

Not sure what process system2 refers to but apparently this is consuming already 99% of the startup time with over 30 seconds.

Here are some additional information about my system:

> version
               _                                
platform       x86_64-w64-mingw32               
arch           x86_64                           
os             mingw32                          
crt            ucrt                             
system         x86_64, mingw32                  
status                                          
major          4                                
minor          3.0                              
year           2023                             
month          04                               
day            21                               
svn rev        84292                            
language       R                                
version.string R version 4.3.0 (2023-04-21 ucrt)
nickname       Already Tomorrow
> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8    LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                    LC_TIME=German_Germany.utf8    

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.3.0 tools_4.3.0
> Sys.info()
       sysname        release        version       nodename        machine          login           user effective_user 
     "Windows"       "10 x64"  "build 19045"     "BCP25636"       "x86-64"       "mklose"       "mklose"       "mklose"
RStudio

2023.12.1 Build 402

© 2009-2024 Posit Software, PBC

"Ocean Storm" Release (4da58325, 2024-01-28) for windows

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.12.1+402 Chrome/116.0.5845.190 Electron/26.2.4 Safari/537.36

RStudio 2023.12.1+402 "Ocean Storm" Release (4da58325ffcff29d157d9264087d4b1ab27f7204, 2024-01-28) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.12.1+402 Chrome/116.0.5845.190 Electron/26.2.4 Safari/537.36

Thanks a lot in advance!

Quick update: Apparently my LAN cable had some issues and the reading/writing speed was severly impacted by that. I am working on a shared network drive and I suspect that this might have caused the delay during startup. Before switching the cable I had reading/writing speeds of around 10 MB/s, and afterwards 300 MB/s. Right now the startup time is much improved, so maybe this has already solved the issue. Here is the updated summaryRprof() output after changing the cable:

> summaryRprof("~/rstudio-trace.Rprof")
$by.self
                  self.time self.pct total.time total.pct
"system2"              2.40    86.33       2.40     86.33
"file"                 0.08     2.88       0.08      2.88
"source"               0.04     1.44       0.16      5.76
"saveRDS"              0.04     1.44       0.04      1.44
".deparseOpts"         0.02     0.72       0.02      0.72
"class"                0.02     0.72       0.02      0.72
"file.exists"          0.02     0.72       0.02      0.72
"findCenvVar"          0.02     0.72       0.02      0.72
"getHook"              0.02     0.72       0.02      0.72
"gettext"              0.02     0.72       0.02      0.72
"inDL"                 0.02     0.72       0.02      0.72
"lazyLoadDBfetch"      0.02     0.72       0.02      0.72
"normalizePath"        0.02     0.72       0.02      0.72
"sys.function"         0.02     0.72       0.02      0.72
"withVisible"          0.02     0.72       0.02      0.72

$by.total
                                    total.time total.pct self.time self.pct
"tryCatch"                                2.72     97.84      0.00     0.00
"tryCatchList"                            2.72     97.84      0.00     0.00
".rs.executeFunctionInChildProcess"       2.44     87.77      0.00     0.00
".rs.inferReticulatePython"               2.44     87.77      0.00     0.00
"system2"                                 2.40     86.33      2.40    86.33
"doTryCatch"                              0.28     10.07      0.00     0.00
"tryCatchOne"                             0.28     10.07      0.00     0.00
"base::try"                               0.20      7.19      0.00     0.00
"source"                                  0.16      5.76      0.04     1.44
"eval"                                    0.16      5.76      0.00     0.00
"eval.parent"                             0.16      5.76      0.00     0.00
"local"                                   0.16      5.76      0.00     0.00
"file"                                    0.08      2.88      0.08     2.88
"loadNamespace"                           0.08      2.88      0.00     0.00
".First.sys"                              0.06      2.16      0.00     0.00
"FUN"                                     0.06      2.16      0.00     0.00
"lapply"                                  0.06      2.16      0.00     0.00
"library"                                 0.06      2.16      0.00     0.00
"require"                                 0.06      2.16      0.00     0.00
"saveRDS"                                 0.04      1.44      0.04     1.44
".rs.packages.initialize"                 0.04      1.44      0.00     0.00
".rs.tutorial.findTutorials"              0.04      1.44      0.00     0.00
".rs.updatePackageEvents"                 0.04      1.44      0.00     0.00
"registerS3methods"                       0.04      1.44      0.00     0.00
"sapply"                                  0.04      1.44      0.00     0.00
"setHook"                                 0.04      1.44      0.00     0.00
"suppressWarnings"                        0.04      1.44      0.00     0.00
"withCallingHandlers"                     0.04      1.44      0.00     0.00
".deparseOpts"                            0.02      0.72      0.02     0.72
"class"                                   0.02      0.72      0.02     0.72
"file.exists"                             0.02      0.72      0.02     0.72
"findCenvVar"                             0.02      0.72      0.02     0.72
"getHook"                                 0.02      0.72      0.02     0.72
"gettext"                                 0.02      0.72      0.02     0.72
"inDL"                                    0.02      0.72      0.02     0.72
"lazyLoadDBfetch"                         0.02      0.72      0.02     0.72
"normalizePath"                           0.02      0.72      0.02     0.72
"sys.function"                            0.02      0.72      0.02     0.72
"withVisible"                             0.02      0.72      0.02     0.72
".identC"                                 0.02      0.72      0.00     0.00
".registerS3method"                       0.02      0.72      0.00     0.00
".rs.httpdPort"                           0.02      0.72      0.00     0.00
".rs.httpdPortIsFunction"                 0.02      0.72      0.00     0.00
".rs.initHelp"                            0.02      0.72      0.00     0.00
"cmp"                                     0.02      0.72      0.00     0.00
"cmpCall"                                 0.02      0.72      0.00     0.00
"cmpfun"                                  0.02      0.72      0.00     0.00
"compiler:::tryCmpfun"                    0.02      0.72      0.00     0.00
"deparse"                                 0.02      0.72      0.00     0.00
"dyn.load"                                0.02      0.72      0.00     0.00
"formals"                                 0.02      0.72      0.00     0.00
"genCode"                                 0.02      0.72      0.00     0.00
"get"                                     0.02      0.72      0.00     0.00
"getInlineInfo"                           0.02      0.72      0.00     0.00
"h"                                       0.02      0.72      0.00     0.00
"library.dynam"                           0.02      0.72      0.00     0.00
"match.arg"                               0.02      0.72      0.00     0.00
"methods::is"                             0.02      0.72      0.00     0.00
"mode"                                    0.02      0.72      0.00     0.00
"namespaceImportFrom"                     0.02      0.72      0.00     0.00
"tools:::R_user_dir"                      0.02      0.72      0.00     0.00
"tryInline"                               0.02      0.72      0.00     0.00

$sample.interval
[1] 0.02

$sampling.time
[1] 2.78

I guess this seems to be the solution, actually I have never expected that the LAN cable is the cause for this. But apparently everything is possible :wink:

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.