-
Notifications
You must be signed in to change notification settings - Fork 81
getTotalMemory() - skip cgroupsv1 max memory.limit_in_bytes (SYN-4433) #3198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3198 +/- ##
==========================================
- Coverage 97.30% 97.20% -0.11%
==========================================
Files 224 224
Lines 44823 44825 +2
==========================================
- Hits 43616 43570 -46
- Misses 1207 1255 +48
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
synapse/lib/platforms/linux.py
Outdated
valu = int(f.read()) | ||
# Skip a known value on cgroupsv1 where there has not been | ||
# a limit set, so we will fallback to /proc/meminfo instead. | ||
if valu != 9223372036854771712: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this SO thread says this value is signed 64-bit max rounded down to nearest page: https://unix.stackexchange.com/questions/420906/what-is-the-value-for-the-cgroups-limit-in-bytes-if-the-memory-is-not-restricte.
That makes more sense than this magic value. I'd recommend changing to one of these:
0x7fffffff_ffffffff ^ 0xfff
or 2**63-1 ^ 0xfff
to be a little more clear. Maybe link the article?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, do we have these constants already defined somewhere? INT64_MAX and PAGESIZE or something equivalent? INT64_MAX ^ (PAGESIZE - 1)
would be really clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PAGESIZE is actually going to be host specific, so we cannot use it as a constant - we can resolve it from os.sysconf('SC_PAGESIZE')
though. We can also assume a 64 bit LONG as well. Will fix this.
No description provided.