-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
perf: Introduce fixed size memory pool for bloom querier #13039
Conversation
1afec2b
to
e49f84b
Compare
c19d417
to
cb7d00d
Compare
docs/sources/shared/configuration.md
Outdated
# and best effort re-cycling of buffers using Go's sync.Pool), fixed (a | ||
# fixed size memory pool with configurable slab sizes, see mem-pool-buckets) | ||
# CLI flag: -bloom.memory-management.alloc-type | ||
[bloom_page_alloc_type: <string> | default = "dynamic"] |
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.
Is this something we want to expose to users? Or do we want to have it to run some experiments and will later remove it?
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.
I think this must be configurable, but it's kind of an "expert setting". We could hide it from the docs
a2cbf40
to
96152ca
Compare
3cae039
to
dbb5bed
Compare
This allows for using different implementations of allocators depending on the use case Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
dbb5bed
to
a122b89
Compare
``` loki_mempool_available_buffers_per_slab{slab="..."} loki_mempool_errors_total{slab="...", reason="..."} ``` Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
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!
Signed-off-by: Christian Haudum <[email protected]>
…ruptions (#13162)" This reverts commit 41c5ee2. Signed-off-by: Christian Haudum <[email protected]>
--- Revert "fix(regression): reverts #13039 to prevent use-after-free corruptions (#13162)" This reverts commit 41c5ee2. Signed-off-by: Christian Haudum <[email protected]>
--- Revert "fix(regression): reverts #13039 to prevent use-after-free corruptions (#13162)" This reverts commit 41c5ee2. Signed-off-by: Christian Haudum <[email protected]>
--- Revert "fix(regression): reverts #13039 to prevent use-after-free corruptions (#13162)" This reverts commit 41c5ee2. Signed-off-by: Christian Haudum <[email protected]>
--- Revert "fix(regression): reverts #13039 to prevent use-after-free corruptions (#13162)" This reverts commit 41c5ee2. Signed-off-by: Christian Haudum <[email protected]>
--- Revert "fix(regression): reverts #13039 to prevent use-after-free corruptions (#13162)" This reverts commit 41c5ee2. Signed-off-by: Christian Haudum <[email protected]>
This PR re-introduces the fixed size memory pool that was originally introduced with #13039 but reverted with #13162 Additionally, it removes the package-global variable to store the type of allocator that should be used. Instead, the allocator type is passed during the bloom store creation. Signed-off-by: Christian Haudum <[email protected]>
What this PR does / why we need it:
This PR introduces a fixed size memory pool for bloom pages that are loaded in the block querier.
The aim of a fixed size pool of
[]byte
buffers is to reduce the amount of allocations, as well as to control the maximum heap size to prevent OOMing of the bloom gateways.Also, with the current usage of a
sync.Pool
, the query parallelism (bloom-gateway.worker-concurrency
andbloom-gateway.block-query-concurrency
) was defined by thebloom.max-query-page-size
(and vice versa), because the max page size could be loadedworkers * concurrency
times at the same time. Most of the time, though, smaller pages are loaded, and therefore concurrency is not optimized.With the new fixed size memory pool, this problem should be solved. The pool is divided into slabs of different sizes holding different amounts of buffers; a larger amount of small sized buffers and a smaller amount of large sized buffers.
TODO
Notes for the reviewer
I'm up for suggestions for naming the configuration options, as well as for the interface name. I don't really like the term
Allocator
in this context.Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR