Rstudio is painfully slow - r

Suddenly, Rstudio is painfully slow, and now it is unusable. This means, I open it up and there is a lag of several seconds if I type anything. I have explored all the options I can come up with:
1. re-installing both R and Rstudio (although I am not 100% sure I could remove all components),
2. trying to reset settings.... the obvious things such as clearing the workspace and the console.
The size of my data is negligible. I cannot think of anything else.... any ideas?
The only observation i can make that shows something could be wrong with the configuration is (sometimes), I see "gctorture false" as a value in the environment.

Just a guess, but ?gctorture says
Provokes garbage collection on (nearly) every memory allocation.
Intended to ferret out memory protection bugs. Also makes R run
_very_ slowly, unfortunately.
which sounds about right for your problem! You could try
gctorture(FALSE)
If that speeds things up, then look for somewhere that this might have been set, e.g., in a .Rprofile (current working directory, or your user home directory, or the installation directory of R; see ?.Rprofile) and make sure that you start R without loading any .Rhistory or .RData files (again in the working directory, your home directory, etc.)

I had a RStudio project with Git Version Control and then it became very slow. I solved the problem by removing the Git Version Control

Related

R Server - Resuming R Session - message hanging or taking 15+min

I frequently work on a R-server environment. However, whenever come back to my work following the last working day, the system often gets stuck with 'resuming r session'. This might take upwards of 5-15min. I try to terminate R or restart R but often this doesn't really do anything.
I'm looking for a work-around as it is very frustrating to go to the R-server URL and to have to wait forever to get started again. IDEALLY, I'd be able to pick up right where I left off. However, if this can't be done, I guess that is ok….
I was looking around at the folder structure and I noticed that there is a folder called "Suspended-R-Session".
Within this folder are a few files such as:
'options',
'lib paths',
'history',
'environment_vars',
'environment',
and 'settings'.
Should I be deleting these files in order to speed up load time???
As described in this link https://support.rstudio.com/hc/en-us/community/posts/200638878-resuming-session-hangup, in my case for R version 3.5:
cd ~/.rstudio/sessions/active/session-45204d30
rm -rf suspended-session-data

How to recover RStudio session after crash?

I would like to know how to restore my previous RStudio session after RStudio and the R session crashed.
Background:
I find that my R session crashes very often, at random times for random reasons. I am fine with that I guess.
Most of the time RStudio restarts the R session and I can continue.
But sometimes it just freezes at which time I noticed power cycling the entire machine allows RStudio to recover and even reload my old session.
Stupid me, I don't think power cycling is a good idea so I manually killed the R session, but then RStudio responded but was not really working so I restarted it and it came back with an empty work-space.
I have been backing up with Session->Save Workspace As, but it seems to do nothing as recovering leaves me with the blank empty environment.
I am looking to restore the RStudio display, including the command history , which for a novice like me is precious, and my list of open scripts, some of which were unsaved at the time of the crash.
I am assuming since RStudio can recover itself, there is a file somewhere I can use to recover it.
And if there is no way to recover, how can I completely save my workspace so this cannot happen again?
Also, is there a proper way to recover from an RStudio freeze without a hard reset?
It has been a while since I asked this question. I was never able to fully recover, but I switched to Rprojects which is the recommended way to use Rstudio.
Rprojects are stored in a folder and they remember all files and data from that project in that folder.
This did not help me with my initial problem, but projects prevent it from happening again. The hard part is moving a work-space to a project if it was not in a project to start.
Hi the first step of this article helped me entirely.
https://datacornering.com/how-to-restore-closed-unsaved-script-in-rstudio/
Basically, if on windows, go to C:\Users\xx\AppData\Local\RStudio\sources\s-xx and find a file with "-contents" at the end. This is your unsaved file.

Automatically log changes to system files and allow revert

I'm trying to learn about the guts of Unix right now, mostly through experimentation. When I was first starting, I found myself looking through forum posts, copying and pasting bash code. When I broke something, I often had to do a fresh install because I couldn't remember what exactly I had changed where. Now, the simple solution is to record a log of all the system files I've changed and keep original copies of all the default files so I can revert if necessary. It would be great if there was a cl tool which did this for me automatically. It would be even greater if I could step back through changes. Basically, I'm looking to version control my entire OS.
Does anything like this exist? I would also accept alternative strategies for spelunking through Unix without causing permanent damage if you think I'm going about this wrong.
Using debian if it matters.

RStudio freezes on "saving workspace image," previously saved .RData file disappears

First, I've also posted this question on the RStudio Support page. If I get a response there, I will post it here for all to see (and vice versa).
I'm enjoying RStudio but am having trouble using Rprojects to save model outputs. I'm running sets of models that take ~1 day to run, so this is really setting me back. This is on an iMac running 10.9.5 (Mavericks).
Here's what happens:
I close the project and allow the "saving workspace image" to go through. (This is taking ~15 min, and the Rdata files are 6GB - this seems surprisingly large to me).
Often there is no problem upon reopening, the Rdata files are restored, and I see the objects I've created in the Global Environment pane. I run another model (or set of them), and close the project again. RStudio now gets hung up on "saving workspace image." Eventually, the wheel showing that this is active stops turning. Sometimes the mouse disappears from the screen and the entire computer freezes.
I either force RStudio to close, or force the computer to shutdown. When I restart and open RStudio, then load the Rproject, the Global Environment is empty. In the Files pane, there are no .RData files shown.
When I check the Rproject directory in Finder, there are multiple .RDataTmp (hidden) files. I'm not clear whether I can use any of them to recover my data, or how to attempt to load them in RStudio.
Solutions I've tried so far:
Updating everything, including R, RStudio, and Safari, per another post on RStudio Support.
Disabling my syncing program (SugarSync) from updating .Rproj.user file, also after reading a post there.
Enabling access for RStudio in the Privacy/Security settings.
I haven't been able to find any other possible solutions, and I am growing frustrated with testing this out, as it seems to happen only intermittently and (sigh) after the problem seems revolved, such that I've run a whole bunch of models and have a good deal of data to lose! This makes me wonder whether (a) the universe is simply cruel, or (b) it's the large file size that is causing the problem. The other option is (c) both.
I read elsewhere on RStudio Support that file compression can be enabled, but that this will slow the process of saving. Since it's already taking quite a long time to save upon closing the project and I'm not clear on why it might help, I'm hesitant to enable file compression until I know more.
Thanks for your help,
MK

RStudio server - Hangs when switching projects

I am currently running RStudio via a server installation that I only partially maintain. I am working with some fairly large data sets and models (> 9 million rows of 611 variables). When I try to switch projects, RStudio hangs when loading the project (it says "Switching projects to..." at the top) or, if it loads, takes forever.
RStudio works otherwise while attempting to switch projects, but menus and the like do not work.
I have searched thoroughly for a fix to no avail. How would I go about troubleshooting (or, ideally, fixing) the problem?
RStudio is running on a linux (Open SuSE) VM.
Thanks in advance.
EDIT: Per this thread: https://stackoverflow.com/a/15373596/3469671, I deleted .rstudio from my home directory and that seemed to free things up. Is there some setting I can change to facilitate the loading of larger projects?
Per this thread, I deleted .rstudio from my home directory and that seemed to free things up.
As a practice, I learned to stop saving my workspace while it was loaded with data and included steps within projects to save and load prepared data.

Resources