Repository navigation
Description
System details
RStudio Edition : Desktop
RStudio Version : RStudio 2024.04.0+735 "Chocolate Cosmos" Release (a00d0e775dbc93e0d79a1bf474e3e8e8de677383, 2024-04-24) for windows Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2024.04.0+735 Chrome/120.0.6099.291 Electron/28.2.6 Safari/537.36, Quarto 1.3.450
OS Version : x86_64-w64-mingw32 (windows 10)
R Version : R version 4.3.0 (2023-04-21 ucrt) (Already Tomorrow)
Steps to reproduce the problem
- Create test.qmd (or test.Rmd) file with the following single chunk of code. Also create test.R with the same code, so just without the {r} chunk markup.
```{r}
# define start time
start_time <- Sys.time()
# dummy code
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
1+1
# define end time
end_time <- Sys.time()
# calculate elapsed time
difftime(end_time, start_time, units = "secs")
```
- Open test.qmd and execute chunk in RStudio within various scenarios. Compare difftime (time to execute chunk)
a) local drive, no project
test.qmd: Time difference of 0.08611608 secs
test.R: Time difference of 0.01601291 secs
b) local drive, within project
test.qmd: Time difference of 0.08609295 secs
test.R: Time difference of 0.01690793 secs
c) mapped / shared network drive, no project
test.qmd: Time difference of 0.26181581 secs
test.R: Time difference of 0.01711988 secs
d) mapped / shared network drive, within project
test.qmd: Time difference of 1.60444383 secs
test.R: Time difference of 0.01676202 secs
Describe the problem in detail
We can see that while the execution of test.R is nearly unaffected by both the project/no project setting and the shared / local drive setting, the test.qmd chunk execution is highly impacted. We can observe a nearly 20-fold longer execution time for the chunk inside test.qmd when comparing the d) mapped / shared network drive, within project scenario with the a) local drive, no project or b) local drive, within project scenarios. The same behaviour is reproducible for test.Rmd instead of test.qmd.
This issue is related to #8034 (which was closed with the request to open a new issue if there are still problems) and #10417.
Describe the behavior you expected
I would expect the same execution time for the chunk inside test.qmd no matter what scenario (a/b/c/d) we are in. To me, this behaviour makes it very hard to use projects and/or Quarto or RMarkdown files when on a mapped / shared network drive.
- I have read the guide for submitting good bug reports.
- I have installed the latest version of RStudio, and confirmed that the issue still persists.
- If I am reporting an RStudio crash, I have included a diagnostics report.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Activity
ronblum commentedon May 6, 2024
See also #10417.
nschan commentedon May 17, 2024
I am experiencing similar problems. I suspect they are related to the use of
renv, are you usingrenv@marianklose ? For me there is a noticable increase in performance afterrenv::deactivate().marianklose commentedon May 17, 2024
Hi @nschan, thanks for your suggestion. For me it is actually not related to
renv. But I haven't tested if usingrenvis slowing down the process even more.kevinushey commentedon May 29, 2024
@marianklose: would you be willing to help us collect some more information? There is a Windows utility called Process Monitor, which can be used to check what system calls a particular process is making. Some instructions:
test.qmdto prepare for running your example code.procmon, and use the following filter to capture RStudio's R session activity:marianklose commentedon May 30, 2024
@kevinushey: Sure, I am happy to help. I am currently on my private windows machine at home connected to my university shared network drive. I am conducting these tests for the two extreme scenarios regarding runtime: a) local drive, no project and d) mapped / shared network drive, within project. Let me know if you also need b) and d).
Here is a screenshot of my
procmonfilter (I unchecked the other filters):I first opened the project, then the .qmd and then opened
procmonand applied the filter. After applying the filter I've waited for 10 seconds before I execute the chunk. I saved the log.csv and log.PML (which I couldn't upload, let me know if you need it).a) local drive, no project
Time difference of 0.588882 secsd) mapped / shared network drive, within project.
Time difference of 56.29842 secsHope that helps! Let me know if you need anything else.
kevinushey commentedon May 30, 2024
Thanks! This is very useful. I think this confirms some of our suspicions -- it looks like filesystem access is fairly slow on the network filesystem you're using, and since chunk execution will somewhat eagerly read and write files within the project's
.Rproj.userfolder, code execution gets slowed down.I have some changes in #14765 that may help for future builds of RStudio, but I feel like the best way to fix this would be to have some way to have the
.Rproj.userfolder's location customized, so you could place it on a faster filesystem (e.g. perhaps a local filesystem). This could have downsides; e.g. your session state wouldn't be preserved if you opened that project on a different machine, but that might be a tradeoff you're willing to make?marianklose commentedon May 31, 2024
Thanks for getting back to me.
Indeed, it will definitely depend on the access speed to the network drive. At home I have a way slower chunk execution time (56 sec) than on my university machine (1.7 sec). On both machines I work on a mapped network drive, but apparently the access speed is higher at university. I can later also share the speed at home, but that's kind of an average writing/reading speed at the university (to and from the network drive):
I don't have a reference if that's fast or slow but this results in 1.7 sec execution time within a project.
Sounds reasonable to me. Personally, the potential downsides are perfectly fine with me. I mainly work with projects to use
here::here()and whenever I work on packages. Preserving the session state is not really a priority to me.One other question: To me it makes sense that extensive reading/writing to the project files slows down the process. When comparing working with
.qmdwithin/without projects there is a huge difference. But if I am on a slow network drive I can still feel a delay when I execute.qmdchunks without being in a project. Are there still some unneccessary reading/writing operations involved even when being outside a project?I was wondering that even without a project the output from a chunk (graphics, tables etc.) is being preserved even if I close the file and Rstudio and then reopen it again:
So for each chunk it needs to preserve this output somewhere, which surely involves writing to the slow network drive. I don't care about the old chunk outputs. Is there an option to turn this off and do you think this could also lead to slowing down the code execution?
kevinushey commentedon May 31, 2024
Are you able to try a recent daily build of RStudio? We recently implemented some optimizations that may help improve performance here:
https://s3.amazonaws.com/rstudio-ide-build/electron/windows/RStudio-2024.07.0-daily-180.exe
I'm also curious if using "Chunk Output in Console" makes a difference on execution performance. From the gear icon in the editor toolbar for the .Rmd document you're editing:
marianklose commentedon Jun 2, 2024
I've just installed the daily build and I have the following runtime (for the .qmd inside the project on the shared network drive):
so it seems to improve the situation (compared to the 50+ seconds with the previous build), but 22 seconds is still pretty slow. Now using "Chunk Output in Console" speeds up the process signficantly (even when being inside a project):
Thanks for pointing this out, maybe this solves already quite some speed issues. But I am wondering why there is such a significant delay when using the inline output option. There must be some kind of inefficient reading/writing process involved. This is also related to my previous question:
Would it be possible to turn off preserving the chunk output for the future (so it doesn't have to be written somewhere when executing a chunk)? Maybe then we could use the inline output option (which is preferred) even with a somewhat slow network drive?
ronblum commentedon Jun 24, 2024
The latest daily builds of the release in progress, Cranberry Hibiscus 2024.07.0, have a fix for this. If anyone is willing to try it out, it would be greatly appreciated. Plese note that the daily builds are meant for testing purposes only, not production.
gtritchie commentedon Jun 25, 2024
Note that the fix requires configuring the project to store
.Rproj.usersomewhere other than the cloud drive, see #14875.marianklose commentedon Jul 1, 2024
Thanks for getting back to this. I am happy to give it a test. Without the fix (new daily build) the estimation time for the chunk inside a project is:
After installing the Cranberry Hibiscus 2024.07.0 daily build and adjusting the project settings (
.Rproj.usermoved to local C:/ drive) accordingly the estimation time is:So we have a substantial improvement (nearly 10-fold) in execution times. Thanks a lot for that! It is not perfectly matching the excution time which we have when the .qmd is also located on the C:/ drive but I personally can live with that.
Thank you!
ronblum commentedon Jul 9, 2024
@marianklose Thank you very much for testing the execution time improvement!