mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02:00
chore: improvements in dash code (#2387)
chore: cosmetic improvements in dash code 1. Better naming 2. Improve improving the interface of ForEachSlot command 3. Wrap the repeating code of updating the bucket version into the UpdateVersion function Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
25d906bce7
commit
1cab6695d7
4 changed files with 107 additions and 108 deletions
|
@ -1313,8 +1313,8 @@ size_t DbSlice::EvictObjects(size_t memory_to_free, PrimeIterator it, DbTable* t
|
|||
PrimeTable::Segment_t* segment = table->prime.GetSegment(it.segment_id());
|
||||
DCHECK(segment);
|
||||
|
||||
constexpr unsigned kNumStashBuckets =
|
||||
PrimeTable::Segment_t::kTotalBuckets - PrimeTable::Segment_t::kNumBuckets;
|
||||
constexpr unsigned kNumStashBuckets = PrimeTable::Segment_t::kStashBucketCnt;
|
||||
constexpr unsigned kNumRegularBuckets = PrimeTable::Segment_t::kRegularBucketCnt;
|
||||
|
||||
PrimeTable::bucket_iterator it2(it);
|
||||
unsigned evicted = 0;
|
||||
|
@ -1329,7 +1329,7 @@ size_t DbSlice::EvictObjects(size_t memory_to_free, PrimeIterator it, DbTable* t
|
|||
};
|
||||
|
||||
for (unsigned i = 0; !evict_succeeded && i < kNumStashBuckets; ++i) {
|
||||
unsigned stash_bid = i + PrimeTable::Segment_t::kNumBuckets;
|
||||
unsigned stash_bid = i + kNumRegularBuckets;
|
||||
const auto& bucket = segment->GetBucket(stash_bid);
|
||||
if (bucket.IsEmpty())
|
||||
continue;
|
||||
|
@ -1360,8 +1360,8 @@ size_t DbSlice::EvictObjects(size_t memory_to_free, PrimeIterator it, DbTable* t
|
|||
// Try normal buckets now. We iterate from largest slot to smallest across the whole segment.
|
||||
for (int slot_id = PrimeTable::Segment_t::kNumSlots - 1; !evict_succeeded && slot_id >= 0;
|
||||
--slot_id) {
|
||||
for (unsigned i = 0; i < PrimeTable::Segment_t::kNumBuckets; ++i) {
|
||||
unsigned bid = (it.bucket_id() + i) % PrimeTable::Segment_t::kNumBuckets;
|
||||
for (unsigned i = 0; i < kNumRegularBuckets; ++i) {
|
||||
unsigned bid = (it.bucket_id() + i) % kNumRegularBuckets;
|
||||
const auto& bucket = segment->GetBucket(bid);
|
||||
if (!bucket.IsBusy(slot_id))
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue