2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-10 09:02:10 +00:00

Merge pull request #712 from Mangesh-Khairnar/redis-fix

[Minor] Redis ram fix
This commit is contained in:
Ameya Shenoy 2018-09-06 13:51:57 +05:30 committed by GitHub
commit 567cd668af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,10 +67,8 @@ def get_redis_version():
return float('{major}.{minor}'.format(major=version.major, minor=version.minor)) return float('{major}.{minor}'.format(major=version.major, minor=version.minor))
def get_max_redis_memory(): def get_max_redis_memory():
total_virtual_mem = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')/(pow(1024, 2)) try:
max_memory = int(total_virtual_mem * 0.05) # Max memory for redis is 5% of virtual memory max_mem = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
except ValueError:
if max_memory < 50: max_mem = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize']).strip())
return 50 return max(50, int((max_mem / (1024. ** 2)) * 0.05))
else:
return max_memory