sstables_manager: introduce reclaim_memory_and_stop_tracking_sstable()
When an sstable is unlinked or deactivated, it should be removed from the component memory tracking metrics and any further reload/reclaim should be disabled. This patch adds a new method that implements the above mentioned functionality. This patch also updates the deactivate() to use the new method. Next patch will use it to disable tracking when an sstable is unlinked. Signed-off-by: Lakshmi Narayanan Sreethar <lakshmi.sreethar@scylladb.com>
This commit is contained in:
@@ -227,15 +227,25 @@ future<> sstables_manager::components_reloader_fiber() {
|
||||
}
|
||||
}
|
||||
|
||||
void sstables_manager::reclaim_memory_and_stop_tracking_sstable(sstable* sst) {
|
||||
// remove the sstable from the memory tracking metrics
|
||||
_total_reclaimable_memory -= sst->total_reclaimable_memory_size();
|
||||
_total_memory_reclaimed -= sst->total_memory_reclaimed();
|
||||
// reclaim any remaining memory from the sstable
|
||||
sst->reclaim_memory_from_components();
|
||||
// disable further reload of components
|
||||
_reclaimed.erase(*sst);
|
||||
sst->disable_component_memory_reload();
|
||||
}
|
||||
|
||||
void sstables_manager::add(sstable* sst) {
|
||||
_active.push_back(*sst);
|
||||
}
|
||||
|
||||
void sstables_manager::deactivate(sstable* sst) {
|
||||
// Remove SSTable from the reclaimable memory tracking
|
||||
_total_reclaimable_memory -= sst->total_reclaimable_memory_size();
|
||||
_total_memory_reclaimed -= sst->total_memory_reclaimed();
|
||||
_reclaimed.erase(*sst);
|
||||
// Drop reclaimable components if they are still in memory
|
||||
// and remove SSTable from the reclaimable memory tracking
|
||||
reclaim_memory_and_stop_tracking_sstable(sst);
|
||||
|
||||
// At this point, sst has a reference count of zero, since we got here from
|
||||
// lw_shared_ptr_deleter<sstables::sstable>::dispose().
|
||||
|
||||
@@ -219,6 +219,10 @@ private:
|
||||
// Fiber to reload reclaimed components back into memory when memory becomes available.
|
||||
future<> components_reloader_fiber();
|
||||
size_t get_memory_available_for_reclaimable_components();
|
||||
// Reclaim memory from the SSTable and remove it from the memory tracking metrics.
|
||||
// The method is idempotent and for an sstable that is deleted, it is called both
|
||||
// during unlink and during deactivation.
|
||||
void reclaim_memory_and_stop_tracking_sstable(sstable* sst);
|
||||
private:
|
||||
db::large_data_handler& get_large_data_handler() const {
|
||||
return _large_data_handler;
|
||||
|
||||
Reference in New Issue
Block a user