-
Notifications
You must be signed in to change notification settings - Fork 3.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
Add the option to configure memory ballast for Loki #5081
Conversation
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, thanks for this @SasSwart!
We'll definitely need some documentation about this, though. Do you mind adding that?
On it. |
Add additional information to Flag description
@dannykopping Done. Added more clarity to flag description as well. |
Sorry, I should've been more clear. We have our docs at https://grafana.com/docs/loki/latest/configuration/ - which is linked to the This is asking a lot so don't feel obligated; we can add that after merging the PR. |
I agree I don't know when I should use it either |
No, it should definitely be on me to add docs for my contribution. |
Add documentation
While adding documentation, I noticed that I wasn't providing a tag for unmarshalling BallastBytes from the config file. I've moved the BallastBytes value to the root config struct instead of the ConfigWrapper and provided the tag. I also removed the option to set this as a Command Line argument in favor of the config file. |
Thanks for this. We generally allow for the setting of important config options via both YAML and CLI; would you mind restoring this one? It can be defined in |
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
Thanks @SasSwart 🙌 |
May I ask what that relates to? Normally I would say, as the code does, it's to reduce garbage-collection. |
Hey @bboreham That would be a wording mistake on my side. When opening the PR, I must've referenced the wrong section of this issue. Thanks for spotting this. I seem to have referred to the top level comment, whereas my contribution is more related to this comment. I'll update the PR description. |
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.
Thanks for the PR! LGTM!
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.
This PR was merged in before my doc suggestions were written. Please consider using the suggestions in further revision.
Memory ballast is cool!
@@ -93,6 +93,12 @@ Pass the `-config.expand-env` flag at the command line to enable this way of set | |||
# if true. If false, the OrgID will always be set to "fake". | |||
[auth_enabled: <boolean> | default = true] | |||
|
|||
# The amount of virtual memory to reserve as a ballast in order to optimise |
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.
Wording suggestion:
Change
The amount of virtual memory to reserve as a ballast in order to optimise
to be
The amount of virtual memory in bytes to reserve as ballast in order to optimize
## Memory Ballast | ||
In compute constrained environments, garbage collection can become a significant factor. This can be optimised, at the expense of memory consumption, by configuring a memory ballast using the `ballast_bytes` configuration option. | ||
|
||
A larger memory ballast will mean that standard heap size volatility is less relatively significant, and therefore less likely to trigger garbage collection. This will result in lower compute overhead, but higher memory consumption, as the heap is cleaned less frequently. |
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.
We use sentence case for headers. Here's my rewrite of this section of prose:
Memory ballast
In compute-constrained environments, garbage collection can become a significant performance factor. Frequently-run garbage collection interferes with running the application by using CPU resources. The use of memory ballast can mitigate the issue. Memory ballast allocates extra, but unused virtual memory in order to inflate the quantity of live heap space. Garbage collection is triggered by the growth of heap space usage. The inflated quantity of heap space reduces the perceived growth, so garbage collection occurs less frequently.
Configure memory ballast using the ballast_bytes
configuration option.
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.
Thanks for the notes @KMiller-Grafana,
I'll prepare a follow up PR with these changes.
* Add memory ballast * Add changelog entry * Add documentation Add additional information to Flag description * Ensure that ballast_bytes can be configured from config file Add documentation * Add Operational scalability documentation related to memory ballast * Restore config.ballast-bytes cli flag * Move config.ballast-bytes cli flag declaration * Update memory ballast documentation as per https://github.com/grafana/loki/pull/5081\#pullrequestreview-848460132 Co-authored-by: Owen Diehl <ow.diehl@gmail.com>
What this PR does / why we need it:
Adds the option to configure a memory ballast in order to enable reducing garbage collection when needed.
Which issue(s) this PR fixes:
Fixes #781
Special notes for your reviewer:
PR Based on reading this, and a comparable PR in cortex.
Checklist
CHANGELOG.md
about the changes.