in src/mount_efs/__init__.py [0:0]
def optimize_readahead_window(mountpoint, options, config):
if not should_revise_readahead(config):
return
fixed_readahead_kb = int(
DEFAULT_NFS_MAX_READAHEAD_MULTIPLIER * int(options["rsize"]) / 1024
)
try:
major, minor = decode_device_number(os.stat(mountpoint).st_dev)
# modify read_ahead_kb in /sys/class/bdi/<bdi>/read_ahead_kb
# The bdi identifier is in the form of MAJOR:MINOR, which can be derived from device number
#
read_ahead_kb_config_file = NFS_READAHEAD_CONFIG_PATH_FORMAT % (major, minor)
logging.debug(
"Modifying value in %s to %s.",
read_ahead_kb_config_file,
str(fixed_readahead_kb),
)
p = subprocess.Popen(
"echo %s > %s" % (fixed_readahead_kb, read_ahead_kb_config_file),
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.DEVNULL,
)
_, error = p.communicate()
if p.returncode != 0:
logging.warning(
'Failed to modify read_ahead_kb: %s with returncode: %d, error: "%s".'
% (fixed_readahead_kb, p.returncode, error.strip())
)
except Exception as e:
logging.warning(
'Failed to modify read_ahead_kb: %s with error: "%s".'
% (fixed_readahead_kb, e)
)