sstables_manager: extract maybe_reclaim_components()

Extract the code from
`increment_total_reclaimable_memory_and_maybe_reclaim()` that reclaims
the components memory into `maybe_reclaim_components()`. The extracted
new method will be used by a following patch to handle reclaim within
the components reload fiber.

Signed-off-by: Lakshmi Narayanan Sreethar <lakshmi.sreethar@scylladb.com>
This commit is contained in:
Lakshmi Narayanan Sreethar
2025-01-30 14:43:22 +05:30
parent 59cbee6fc7
commit 4d12ae433a
2 changed files with 5 additions and 0 deletions

View File

@@ -154,7 +154,10 @@ sstable_writer_config sstables_manager::configure_writer(sstring origin) const {
void sstables_manager::increment_total_reclaimable_memory_and_maybe_reclaim(sstable* sst) {
_total_reclaimable_memory += sst->total_reclaimable_memory_size();
maybe_reclaim_components();
}
void sstables_manager::maybe_reclaim_components() {
size_t memory_reclaim_threshold = _available_memory * _db_config.components_memory_reclaim_threshold();
if (_total_reclaimable_memory <= memory_reclaim_threshold) {
// total memory used is within limit; no need to reclaim.

View File

@@ -218,6 +218,8 @@ private:
void increment_total_reclaimable_memory_and_maybe_reclaim(sstable* sst);
// Fiber to reload reclaimed components back into memory when memory becomes available.
future<> components_reloader_fiber();
// Reclaims components from SSTables if total memory usage exceeds the threshold.
void maybe_reclaim_components();
// Reloads components from reclaimed SSTables if memory is available.
future<> maybe_reload_components();
size_t get_memory_available_for_reclaimable_components();