-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support setting ballast size in percentage of total Mem in ballast extension #3456
Conversation
@mxiamxia can you fix these failing tests. Thx. |
@Aneurysm9 @anuraaga could you please take a look? |
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.
Cool feature
@anuraaga @Aneurysm9 can you please re-review? The tests are now passing. |
…upported for containers and physical hosts
Hi @anuraaga @bogdandrutu @tigrannajaryan @rakyll , PTAL! Thanks. |
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.
@tigrannajaryan @rakyll PTAL, will merge tomorrow otherwise
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.
LGTM, except I have just found we also have a built-in ballast implementation in
opentelemetry-collector/service/collector.go
Line 317 in 6cafee9
func (col *Collector) createMemoryBallast() ([]byte, uint64) { |
I am confused. Why do we have 2 implementations? Are they related or competing?
This old one is taking the |
@bogdandrutu this PR is ready to be merged. :-) |
Descritpion:
Enhance the current ballast extension which is to set memory ballast for the collector process. And we'll remove
--mem-ballast-size-mib
support from command line later.The changes,
Added new configuration
size_in_percentage
which can dynamically set ballast size based on the total memory of the running environments. (hosts, Docker, K8s, etc)Sample Config,
How ballast size is calculated by percentage setup
When
size_in_percentage
is enabled with the value(1-100), theballast_size
will be calculated bysize_in_percentage * totalMemory
. ThetotalMemory
will be calculated for hosts and containers(in docker, k8s, etc) by the following steps,Look up Memory Cgroup subsystem where the collector is running on(it could be container, VM or bare metal host), check if there is total memory limitation has been set for the collector process.
The total assigned memory for the process is in
memory.limit_in_bytes
file under cgroup (eg,/sys/fs/cgroup/memory/memory.limit_in_bytes
).If
memory.limit_in_bytes
has a positive value other than9223372036854771712
. Theballest_size
will be calculated by
memory.limit_in_bytes * size_in_percentage
. Else Ifmemory.limit_in_bytes
value is9223372036854771712
(0x7FFFFFFFFFFFF000
), it indicates there is no memory limit has been set for the collector process in cgroup. Then thetotalMemoery
will be determined in the next stepif there is no memory limit set in cgroup for the collector process or container where the collector is running. The total memory will be calculated by
github.com/shirou/gopsutil/mem
which is supported in multiple OS systems.Link to tracking Issue:
#2516
Test:
Tested locally on EC2, Docker and K8S for
ballast_size_in_percentage
configuration