Skip to content

Commit 5f076af

Browse files
committed
more fixes
1 parent 48982cc commit 5f076af

5 files changed

Lines changed: 12 additions & 20 deletions

File tree

src/server/tiered_storage.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class TieredStorage::ShardOpManager : public tiering::OpManager {
225225
bool NotifyFetched(const OwnedEntryId& id, tiering::DiskSegment segment,
226226
tiering::Decoder* decoder) override;
227227

228-
bool NotifyDelete(tiering::DiskSegment segment, bool was_read) override;
228+
bool NotifyDelete(tiering::DiskSegment segment, bool in_memory) override;
229229

230230
void EnqueueForDefrag(tiering::DiskSegment segment);
231231

@@ -414,7 +414,7 @@ bool TieredStorage::ShardOpManager::NotifyFetched(const OwnedEntryId& id,
414414
return false;
415415
}
416416

417-
bool TieredStorage::ShardOpManager::NotifyDelete(tiering::DiskSegment segment, bool was_read) {
417+
bool TieredStorage::ShardOpManager::NotifyDelete(tiering::DiskSegment segment, bool in_memory) {
418418
DVLOG(2) << "NotifyDelete [" << segment.offset << "," << segment.length << "]";
419419

420420
if (OccupiesWholePages(segment.length))
@@ -428,8 +428,8 @@ bool TieredStorage::ShardOpManager::NotifyDelete(tiering::DiskSegment segment, b
428428
// If we have memory, upload the page for defrag. It will be reshuffled and offloaded more packed.
429429
// Otherwise background scans of fragmented bins will discover them
430430
if (bin.fragmented && ts_->UploadBudget() > 0) {
431-
// Limit number of IO operations if we need to read from disk (was_read is false)
432-
if (was_read || stats_.pending_defrags < kMaxPendingDefrags) {
431+
// Limit number of IO operations if we need to read from disk (in_memory is false)
432+
if (in_memory || stats_.pending_defrags < kMaxPendingDefrags) {
433433
EnqueueForDefrag(bin.segment);
434434
}
435435
}
@@ -668,7 +668,7 @@ void TieredStorage::RunOffloading(DbIndex dbid) {
668668

669669
const auto start_cycles = base::CycleClock::Now();
670670

671-
// Takes up a small fixed amount of time and is best done before offloading (to be picked up)
671+
// Takes up a small bounded amount of time and is best done before offloading (to be picked up)
672672
RunDefragScan();
673673

674674
// Don't run offloading if there's only very little space left

src/server/tiering/op_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ class OpManager {
9494
virtual bool NotifyFetched(const OwnedEntryId& id, DiskSegment segment, Decoder*) = 0;
9595

9696
// Notify delete. Return true if the filled segment needs to be marked as free.
97-
// Under was_read this function was called after a read completion as the follow-up delete
97+
// Under in_memory this function was called after a read completion as the follow-up delete
9898
// operation - the full page is still in the op_managers pending operations cache
99-
virtual bool NotifyDelete(DiskSegment segment, bool was_read) = 0;
99+
virtual bool NotifyDelete(DiskSegment segment, bool in_memory) = 0;
100100

101101
// Describes pending read futures for a single entry
102102
struct EntryOps {

src/server/tiering/op_manager_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct OpManagerTest : PoolTestBase, OpManager {
7878
return false;
7979
}
8080

81-
bool NotifyDelete(DiskSegment segment, bool from_read) override {
81+
bool NotifyDelete(DiskSegment segment, bool in_memory) override {
8282
return true;
8383
}
8484

src/server/tiering/small_bins.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ size_t SmallBins::SerializeBin(FilledBin* bin, io::MutableBytes dest) {
8585
}
8686

8787
SmallBins::KeySegmentList SmallBins::ReportStashed(BinId id, DiskSegment segment) {
88-
DVLOG(1) << "ReportStashed " << id;
88+
DCHECK(pending_bins_.contains(id)); // valid pending operation id
89+
DCHECK(stashed_bins_.Find(segment.offset).is_done()); // new unoccupied destination
8990

90-
DCHECK(pending_bins_.contains(id));
9191
auto seg_map_node = pending_bins_.extract(id);
9292
const auto& seg_map = seg_map_node.mapped();
9393
DCHECK_GT(seg_map.size(), 0u) << id;

src/server/tiering/small_bins.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,8 @@ class SmallBins {
122122
}
123123

124124
static uint64_t HashFn(uint64_t v) {
125-
// Keys are page-aligned disk offsets (multiples of kPageSize), so their low bits are always
126-
// zero and their high bits are zero for small files. std::hash<uint64_t> is the identity on
127-
// libstdc++, which would funnel every bin into a single segment and make DashTable split
128-
// forever. Mix the bits (murmur3 fmix64) so offsets distribute evenly.
129-
v ^= v >> 33;
130-
v *= 0xff51afd7ed558ccdULL;
131-
v ^= v >> 33;
132-
v *= 0xc4ceb9fe1a85ec53ULL;
133-
v ^= v >> 33;
134-
return v;
125+
// Keys are page alined (% 4096 = 0) which breaks hashing, so scale down to page index
126+
return v / kPageSize;
135127
}
136128
};
137129

0 commit comments

Comments
 (0)