Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release_notes/release_notes-0.15.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Key Features and Updates
* FEAT-#4320: Add connectorx as an alternative engine for read_sql (#4346)
* Benchmarking enhancements
* FEAT-#4371: Add logging to Modin (#4372)
* FEAT-#4501: Add RSS Memory Profiling to Modin Logging (#4502)
* Refactor Codebase
* REFACTOR-#4284: use variable length unpacking when getting results from `deploy` function (#4285)
* REFACTOR-#3642: Move PyArrow storage format usage from main feature to experimental ones (#4374)
Expand Down
34 changes: 34 additions & 0 deletions modin/config/envvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
13 changes: 10 additions & 3 deletions modin/logging/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

import logging
from logging.handlers import RotatingFileHandler
import datetime as dt
import os
import uuid
Expand All @@ -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

Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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)


Expand Down