Skip to content

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

Merged
merged 3 commits into from
Jun 29, 2023

Conversation

vEpiphyte
Copy link
Contributor

No description provided.

@vEpiphyte vEpiphyte added the bug label Jun 26, 2023
@vEpiphyte vEpiphyte added this to the v2.140.0 milestone Jun 26, 2023
@vEpiphyte vEpiphyte marked this pull request as ready for review June 26, 2023 19:42
@codecov
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.11 ⚠️

Comparison is base (d95c222) 97.30% compared to head (138ea0b) 97.20%.

❗ Current head 138ea0b differs from pull request most recent head a5d3529. Consider uploading reports for the commit a5d3529 to get more accurate results

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     
Flag Coverage Δ
linux 97.20% <100.00%> (-0.01%) ⬇️
linux_replay ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
synapse/lib/platforms/linux.py 84.25% <100.00%> (+0.29%) ⬆️

... and 10 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@vEpiphyte vEpiphyte requested review from invisig0th, Cisphyx, mikemoritz and a user June 27, 2023 13:31
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:
Copy link

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?

Copy link

@ghost ghost Jun 27, 2023

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.

Copy link
Contributor Author

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.

ghost
ghost previously approved these changes Jun 28, 2023
@vEpiphyte vEpiphyte changed the title getTotalMemory() - skip known unset value on memory.limit_in_bytes (SYN-4433) getTotalMemory() - skip cgroupsv1 max memory.limit_in_bytes (SYN-4433) Jun 29, 2023
@vEpiphyte vEpiphyte merged commit eab0564 into master Jun 29, 2023
@vEpiphyte vEpiphyte deleted the bug_gettotalmemory branch June 29, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants