How memory metrics are calculated in YugabyteDB yb-tserver process

How memory metrics are calculated in YugabyteDB yb-tserver process

We want to understand what are the memory metrics that need to be sum up to match with this RAM usage from the admin dashboard (tserver).

Currently, we use both server and tcmalloc memory usage combined. But the value is still off around ~10GB:

root->server memory: mem_tracker_server
tcmalloc: tcmalloc_pageheap_free_bytes + tcmalloc_max_total_thread_cache_bytes + tcmalloc_current_total_thread_cache_bytes

enter image description here

Answer

The RAM Used field displayed is the server->root memory tracker for that TServer.

The mem_tracker_server Prometheus metric for recent versions should have the value of server->root, which should agree with the number you are seeing in the UI.

The root tracker pulls information directly from TCMalloc about the actual total memory used by the application. It should include TCMalloc overhead already so you don't need to adjust it using the TCMalloc metrics.

Note that not all TServer memory is captured by root; in particular things like thread stacks and memory mapped index files are not captured. Those usually don't amount to too much memory, however.

The other category of memory usage that contributes to TServer RSS is "memory offered back to the operating system that it has chosen not to take (yet)". This can amount to a substantial amount of memory if transparent huge pages are turned on but not tuned well.

Enjoyed this question?

Check out more content on our blog or follow us on social media.

Browse more questions