Use /tmp instead of /dev/shm for object store on Linux if /dev/shm is too small. (#3149)

* Use /tmp instead of /dev/shm for object store on Linux if /dev/shm is too small.

* Add logging statement and address comments.

* Fix
This commit is contained in:
Robert Nishihara
2018-10-28 20:09:06 -07:00
committed by Philipp Moritz
parent 08fc9e5bcd
commit 9868af4c7c
4 changed files with 107 additions and 42 deletions
+22
View File
@@ -324,6 +324,28 @@ def get_system_memory():
return sysctl(["sysctl", "hw.memsize"])
def get_shared_memory_bytes():
"""Get the size of the shared memory file system.
Returns:
The size of the shared memory file system in bytes.
"""
# Make sure this is only called on Linux.
assert sys.platform == "linux" or sys.platform == "linux2"
shm_fd = os.open("/dev/shm", os.O_RDONLY)
try:
shm_fs_stats = os.fstatvfs(shm_fd)
# The value shm_fs_stats.f_bsize is the block size and the
# value shm_fs_stats.f_bavail is the number of available
# blocks.
shm_avail = shm_fs_stats.f_bsize * shm_fs_stats.f_bavail
finally:
os.close(shm_fd)
return shm_avail
def check_oversized_pickle(pickled, name, obj_type, worker):
"""Send a warning message if the pickled object is too large.