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

Made storage::readers_cache size limitted #16846

Merged
merged 4 commits into from
Mar 7, 2024

Conversation

mmaslankaprv
Copy link
Member

@mmaslankaprv mmaslankaprv commented Mar 4, 2024

Added size based eviction to storage::readers_cache. Previously the
eviction was only time based which may lead to a problem when multiple
readers were created for the same NTP. Now with the size based eviction
the readers cache size is bounded and will not grow indefinitely.

Note on backward compatibility:

Previously the size of cache was unbounded. In this commit we change the
policy to keep up to 200 readers per ntp. This number is still large
enough not cause any issues as it would mean that there are 200
concurrent readers reading a single partition at the same time.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x

Release Notes

Improvements

  • better control of memory usage in storage layer.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
Copy link
Contributor

@andrwng andrwng left a comment

Choose a reason for hiding this comment

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

This looks good, but I'm wondering about the decision to have this be a soft limit

src/v/storage/readers_cache.cc Outdated Show resolved Hide resolved
src/v/storage/readers_cache.cc Outdated Show resolved Hide resolved
src/v/storage/readers_cache.cc Outdated Show resolved Hide resolved
Added property which allows controlling maximum number of readers kept
in cache per ntp. The value was previously unbounded which may lead to
a situation in which readers cache grew and caused out of memory error.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
@piyushredpanda piyushredpanda added this to the v23.3.7 milestone Mar 7, 2024
Added size based eviction to `storage::readers_cache`. Previously the
eviction was only time based which may lead to a problem when multiple
readers were created for the same NTP. Now with the size based eviction
the readers cache size is bounded and will not grow indefinitely.

Note on backward compatibility:

Previously the size of cache was unbounded. In this commit we change the
policy to keep up to 200 readers per ntp. This number is still large
enough not cause any issues as it would mean that there are 200
concurrent readers reading a single partition at the same time.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
Added jitter to readers cache eviction timer to prevent all eviction
timers from firing at the same time.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
*this,
"readers_cache_target_max_size",
"Maximum desired number of readers cached per ntp. This a soft limit, a "
"number of readers in cache may temporary increase as cleanup is done in "
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: temporarily

@andrwng
Copy link
Contributor

andrwng commented Mar 7, 2024

LGTM! Thanks for changing the approach

@andrwng andrwng merged commit d39e7da into redpanda-data:dev Mar 7, 2024
16 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x

@vbotbuildovich
Copy link
Collaborator

/backport v23.2.x

@vbotbuildovich
Copy link
Collaborator

Failed to create a backport PR to v23.3.x branch. I tried:

git remote add upstream https://github.com/redpanda-data/redpanda.git
git fetch --all
git checkout -b backport-pr-16846-v23.3.x-622 remotes/upstream/v23.3.x
git cherry-pick -x 427805735957293efd6dd9ff553fe55ef0922b56 4399ba422df04c1ac1cb2fc7fa4c5f9d352bda4d a494de610eb2a44045ad74553eced3dc5dd30714 d3b07defa19e25950524f31cb48dc4db310e8a37

Workflow run logs.

@vbotbuildovich
Copy link
Collaborator

Failed to create a backport PR to v23.2.x branch. I tried:

git remote add upstream https://github.com/redpanda-data/redpanda.git
git fetch --all
git checkout -b backport-pr-16846-v23.2.x-865 remotes/upstream/v23.2.x
git cherry-pick -x 427805735957293efd6dd9ff553fe55ef0922b56 4399ba422df04c1ac1cb2fc7fa4c5f9d352bda4d a494de610eb2a44045ad74553eced3dc5dd30714 d3b07defa19e25950524f31cb48dc4db310e8a37

Workflow run logs.

Copy link
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

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

From the cover letter

which may lead to a problem when multiple
readers were created for the same NTP.

what's the problem?

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.

None yet

5 participants