Skip to content
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

[ML] Report the "actual" memory usage of the autodetect process #2846

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

edsavage
Copy link
Contributor

@edsavage edsavage commented Apr 4, 2025

Determine the actual memory usage of the autodetect process as reported by the OS, e.g. on Linux this would be the value of the maximum resident set size returned by a call to getrusage.

Add this value to the model size stats record returned to the ES Java process so it can be included in the job counts tab for anomaly detection jobs.

Relates elastic/elasticsearch#126256

Determine the actual memory usgae of the autodetect process as reported by the OS, e.g. on Linux this mould be the value of the maximum resident set size returned by a call to `getrusage`.

Add this value to the model size stats record returned to the ES Java process so it can be included in the `job counts` tab for anomaly detection jobs.
Copy link
Contributor

@valeriy42 valeriy42 left a comment

Choose a reason for hiding this comment

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

Hi Ed. I did the first pass.

We should discuss the naming of the new field. While "actual" conveys the intention of the value, it is confusing to the user.

Also, does maximum resident set size actually correspond to the actual current memory usage or is it the historical peak process memory usage?

@@ -180,6 +181,8 @@ class MODEL_EXPORT CResourceMonitor {
//! Returns the sum of used memory plus any extra memory
std::size_t totalMemory() const;

std::size_t actualMemoryUsage() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can come up with something better than actualMemoryUsage. Maybe: systemMemoryUsage?

@@ -83,7 +84,8 @@ int main(int argc, char** argv) {
ml::counter_t::E_TSADNumberMemoryLimitModelCreationFailures,
ml::counter_t::E_TSADNumberPrunedItems,
ml::counter_t::E_TSADAssignmentMemoryBasis,
ml::counter_t::E_TSADOutputMemoryAllocatorUsage};
ml::counter_t::E_TSADOutputMemoryAllocatorUsage,
ml::counter_t::E_TSADMaxResidentSetSize};
Copy link
Contributor

Choose a reason for hiding this comment

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

Does reporting only the maximum resident set size make sense? Can we also collect the current resident set size?

@edsavage
Copy link
Contributor Author

edsavage commented Apr 8, 2025

Also, does maximum resident set size actually correspond to the actual current memory usage or is it the historical peak process memory usage?

The resident set size (RSS) represents the process's current RAM usage (so not counting pages that have been swapped out etc.), and the max RSS is the high water mark of that value. I think that reporting both would be useful for our purposes.

* ActualMemory -> SystemMemory
* Report current resident set size as well as max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants