Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Functionality to Restart R Within R-Instat #9319

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

N-thony
Copy link
Collaborator

@N-thony N-thony commented Dec 19, 2024

Fixes partially #9308
@rdstern @jkmusyoka, this is a draft implementation of the functionality for restarting R within R-Instat. Please review and share your feedback.

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony this seems to work fine. I'm approving and expecting @Patowhiz to also check.
I tried to look at why you might want to do this and it seems that it largely to do with the way R uses memory.
This nicely completes the main tasks in the Tools menu. Should we now just get rid of the Run R Code and Save Current Options items? That could be a separate pull request.

@N-thony
Copy link
Collaborator Author

N-thony commented Dec 20, 2024

@N-thony this seems to work fine. I'm approving and expecting @Patowhiz to also check. I tried to look at why you might want to do this and it seems that it largely to do with the way R uses memory. This nicely completes the main tasks in the Tools menu. Should we now just get rid of the Run R Code and Save Current Options items? That could be a separate pull request.

@rdstern this is just a draft, I'm looking forward to replicate the RStudio restart system in R-Instat. The memory usage is increasing in this feature because this is not fully implemented.

What's Missing
To fully replicate a restart as in RStudio, the following aspects should be addressed:

  1. Session-Level Restart:
  • A complete R session restart requires tearing down and reinitializing the R process itself. The function currently clears the global environment but does not fully restart the underlying R process.
  1. Unload and Reload Libraries:
  • In RStudio, restarting a session unloads all loaded packages. This function does not handle unloading or reloading of R libraries, which could leave behind lingering dependencies or package states.
  1. Startup Configuration:
  • RStudio restarts with a clean environment, reloading any .Rprofile or startup scripts. The current function does not reinitialize such configurations.
  1. Garbage Collection:
  • The function does not explicitly trigger garbage collection before or after restarting, which might leave unused memory fragments.
  1. Persistent Objects:
  • Objects outside the global environment, such as options (options()) or temporary files, may still persist. These are typically reset in a full R session restart.

Once this is done, I think we will have a nice Restart system.

@N-thony
Copy link
Collaborator Author

N-thony commented Jan 22, 2025

@rdstern, I think this will work efficiently especially once we start using R-Instat packages developed by Lily.
I will get back to this once it fully implemented. Meanwhile I will try it out in a different branch offline with using R-Instat packages from our GitHub.

@rdstern
Copy link
Collaborator

rdstern commented Jan 23, 2025

@ChrisMarsh82 could you please also look at this one? It mirrors a facility in RStudio and we have asumed it in the Tools menu from the start. And maybe merge once you are ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants