Skip to content

Return total memory when limit is max value.#2214

Merged
stevejgordon merged 10 commits intomainfrom
cgroup-memory
Nov 15, 2023
Merged

Return total memory when limit is max value.#2214
stevejgordon merged 10 commits intomainfrom
cgroup-memory

Conversation

@stevejgordon
Copy link
Copy Markdown
Contributor

@stevejgordon stevejgordon commented Nov 3, 2023

On cgroup v1 the process is unlimited when memory.limit_in_bytes has a value of "9223372036854771712". On cgroup v2 it is when memory.max has a value of "max". In either case, we now return the total memory for this metric.

Relates to elastic/apm#814

Closes #2125

Also removed inactive_file.bytes per elastic/apm#339

In the process of refactoring and updating the code in the PR, I took the opportunity to profile the code and reduce the allocation overhead of getting metric samples for two providers.

CGroup Metric Provider

LINUX:

|              Method |     Mean |     Error |    StdDev |    Ratio | RatioSD |   Gen0 |   Gen1 | Allocated | Alloc Ratio |
|-------------------- |---------:|----------:|----------:|---------:|--------:|-------:|-------:|----------:|------------:|
|  GetSamplesOriginal | 9.643 us | 0.1600 us | 0.1418 us | baseline |         | 2.3346 | 0.0610 |   29328 B |             |
|          GetSamples | 5.525 us | 0.0580 us | 0.0569 us |     -43% |    1.6% | 0.0534 |      - |     469 B |        -98% |

Free and Total Memory Provider

WINDOWS:

|             Method |     Mean |    Error |   StdDev |    Ratio | RatioSD |   Gen0 | Allocated | Alloc Ratio |
|------------------- |---------:|---------:|---------:|---------:|--------:|-------:|----------:|------------:|
| GetSamplesOriginal | 600.1 ns | 12.00 ns | 17.22 ns | baseline |         | 0.0277 |     352 B |             |
|         GetSamples | 553.8 ns | 10.57 ns | 12.98 ns |      -8% |    3.2% | 0.0162 |     208 B |        -41% |

LINUX:

|             Method |       Mean |    Error |    StdDev |    Ratio | RatioSD |   Gen0 |   Gen1 | Allocated | Alloc Ratio |
|------------------- |-----------:|---------:|----------:|---------:|--------:|-------:|-------:|----------:|------------:|
| GetSamplesOriginal | 3,693.2 ns | 73.86 ns | 108.27 ns | baseline |         | 0.7324 | 0.0191 |    9216 B |             |
|         GetSamples |   438.7 ns |  8.57 ns |   8.41 ns |     -88% |    3.1% | 0.0215 |      - |     272 B |        -97% |

Mpdreamz
Mpdreamz previously approved these changes Nov 13, 2023
Copy link
Copy Markdown
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 left a few nitpicks.

@stevejgordon stevejgordon merged commit edf2bc1 into main Nov 15, 2023
@stevejgordon stevejgordon deleted the cgroup-memory branch November 15, 2023 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[META 814] Normalize metrics reported based on cgroup in all APM agents

3 participants