Repository: modin-project/modin

Issue:
Add RSS Memory to Modin Logging
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. What kind of performance improvements would you like to see with this new API?



Discussion:

Resolving patch:
diff --git a/modin/config/envvars.py b/modin/config/envvars.py
--- a/modin/config/envvars.py
+++ b/modin/config/envvars.py
@@ -415,6 +415,40 @@ def get(cls):
         return log_memory_interval
 
 
+class LogMemorySize(EnvironmentVariable, type=int):
+    """Size of logs (in MBs) to store per Modin job."""
+
+    varname = "MODIN_LOG_MEMORY_SIZE"
+    default = 100
+
+    @classmethod
+    def put(cls, value):
+        """
+        Set ``LogMemorySize`` with extra checks.
+
+        Parameters
+        ----------
+        value : int
+            Config value to set.
+        """
+        if value <= 0:
+            raise ValueError(f"Log memory size should be > 0 MB, passed value {value}")
+        super().put(value)
+
+    @classmethod
+    def get(cls):
+        """
+        Get ``LogMemorySize`` with extra checks.
+
+        Returns
+        -------
+        int
+        """
+        log_memory_size = super().get()
+        assert log_memory_size > 0, "`LogMemorySize` should be > 0"
+        return log_memory_size
+
+
 class PersistentPickle(EnvironmentVariable, type=bool):
     """Wheather serialization should be persistent."""
 
diff --git a/modin/logging/config.py b/modin/logging/config.py
--- a/modin/logging/config.py
+++ b/modin/logging/config.py
@@ -18,6 +18,7 @@
 """
 
 import logging
+from logging.handlers import RotatingFileHandler
 import datetime as dt
 import os
 import uuid
@@ -26,7 +27,7 @@
 import pkg_resources
 import threading
 import time
-from modin.config import LogMemoryInterval, LogMode
+from modin.config import LogMemoryInterval, LogMemorySize, LogMode
 
 __LOGGER_CONFIGURED__: bool = False
 
@@ -96,7 +97,12 @@ def configure_logging():
 
     os.makedirs(os.path.dirname(log_filename), exist_ok=True)
 
-    logfile = logging.FileHandler(log_filename, "a")
+    logfile = RotatingFileHandler(
+        filename=log_filename,
+        mode="a",
+        maxBytes=LogMemorySize.get() * int(1e5),
+        backupCount=10,
+    )
     formatter = ModinFormatter(
         fmt="%(process)d, %(thread)d, %(asctime)s, %(message)s",
         datefmt="%Y-%m-%d,%H:%M:%S.%f",
@@ -108,7 +114,6 @@ def configure_logging():
         logger.setLevel(logging.INFO)
     logger.setLevel(logging.DEBUG)
 
-    logger = logging.getLogger("modin.logger")
     logger.info(f"OS Version: {platform.platform()}")
     logger.info(f"Python Version: {platform.python_version()}")
     modin_version = pkg_resources.get_distribution("modin").version
@@ -144,8 +149,10 @@ def memory_thread(logger, sleep_time):
         The interval at which to profile system memory.
     """
     while True:
+        rss_mem = bytes_int_to_str(psutil.Process().memory_info().rss)
         svmem = psutil.virtual_memory()
         logger.info(f"Memory Percentage: {svmem.percent}%")
+        logger.info(f"RSS Memory: {rss_mem}")
         time.sleep(sleep_time)
 
 


Test patch: