Skip to content

Commit 6126ae2

Browse files
committed
tmp
Signed-off-by: Vladislav Oleshko <[email protected]>
1 parent 3b0decc commit 6126ae2

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

src/core/detail/listpack_wrap.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ ListpackWrap ListpackWrap::WithCapacity(size_t capacity) {
3737
return ListpackWrap{lpNew(capacity)};
3838
}
3939

40-
ListpackWrap ListpackWrap::WithCapacity(size_t capacity) {
41-
return ListpackWrap{lpNew(capacity)};
42-
}
43-
4440
uint8_t* ListpackWrap::GetPointer() {
4541
return lp_;
4642
}
@@ -106,6 +102,10 @@ size_t ListpackWrap::size() const {
106102
return lpLength(lp_) / 2;
107103
}
108104

105+
size_t ListpackWrap::DataBytes() const {
106+
return lpBytes(lp_);
107+
}
108+
109109
ListpackWrap::Iterator ListpackWrap::begin() const {
110110
return Iterator{lp_, lpFirst(lp_), intbuf_};
111111
}

src/core/detail/listpack_wrap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct ListpackWrap {
5858
Iterator end() const;
5959
size_t size() const; // number of entries
6060

61+
size_t DataBytes() const;
62+
6163
// Get view from raw listpack iterator
6264
static std::string_view GetView(uint8_t* lp_it, uint8_t int_buf[]);
6365

src/server/tiered_storage.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,7 @@ class TieredStorage::ShardOpManager : public tiering::OpManager {
222222
stats->tiered_used_bytes += segment.length;
223223
stats_.total_stashes++;
224224

225-
<<<<<<< HEAD
226225
CompactObj::ExternalRep rep = DetermineSerializationParams(*pv).second;
227-
=======
228-
CompactObj::ExternalRep rep = EstimateSerializedSize(*pv)->second;
229-
>>>>>>> 77a24f54 (feat(tiering): Serialize hashes)
230226
if (ts_->config_.experimental_cooling) {
231227
RetireColdEntries(pv->MallocUsed());
232228
ts_->CoolDown(key.first, key.second, segment, rep, pv);
@@ -711,13 +707,8 @@ bool TieredStorage::ShouldStash(const PrimeValue& pv) const {
711707
}
712708

713709
void TieredStorage::CoolDown(DbIndex db_ind, std::string_view str,
714-
<<<<<<< HEAD
715710
const tiering::DiskSegment& segment, CompactObj::ExternalRep rep,
716711
PrimeValue* pv) {
717-
=======
718-
const tiering::DiskSegment& segment, PrimeValue* pv,
719-
CompactObj::ExternalRep rep) {
720-
>>>>>>> 5b1ceb13 (cooling fixes)
721712
detail::TieredColdRecord* record = CompactObj::AllocateMR<detail::TieredColdRecord>();
722713
cool_queue_.push_front(*record);
723714
stats_.cool_memory_used += (sizeof(detail::TieredColdRecord) + pv->MallocUsed());
@@ -727,11 +718,7 @@ void TieredStorage::CoolDown(DbIndex db_ind, std::string_view str,
727718
record->page_index = segment.offset / tiering::kPageSize;
728719
record->value = std::move(*pv);
729720

730-
<<<<<<< HEAD
731721
pv->SetCool(segment.offset, segment.length, rep, record);
732-
=======
733-
pv->SetCool(segment.offset, segment.length, record, rep);
734-
>>>>>>> 5b1ceb13 (cooling fixes)
735722
}
736723

737724
PrimeValue TieredStorage::Warmup(DbIndex dbid, PrimeValue::CoolItem item) {

src/server/tiered_storage_test.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ TEST_P(LatentCoolingTSTest, SimpleHash) {
516516
// Wait for all to be stashed or in end up in bins
517517
ExpectConditionWithinTimeout([=] {
518518
auto metrics = GetMetrics();
519+
VLOG(0) << metrics.tiered_stats.total_stashes << " "
520+
<< metrics.tiered_stats.small_bins_entries_cnt;
519521
return metrics.tiered_stats.total_stashes +
520522
metrics.tiered_stats.small_bins_filling_entries_cnt ==
521523
kNUM;
@@ -530,6 +532,21 @@ TEST_P(LatentCoolingTSTest, SimpleHash) {
530532
auto v = string{31, 'x'} + 'f';
531533
EXPECT_EQ(resp, v);
532534
}
535+
536+
// Wait for all offloads again
537+
ExpectConditionWithinTimeout([=] {
538+
auto metrics = GetMetrics();
539+
return metrics.db_stats[0].tiered_entries +
540+
metrics.tiered_stats.small_bins_filling_entries_cnt ==
541+
kNUM;
542+
});
543+
544+
// HDEL
545+
for (size_t i = 0; i < kNUM; i++) {
546+
string key = absl::StrCat("k", i);
547+
EXPECT_THAT(Run({"DEL", key, string{1, 'c'}}), IntArg(1));
548+
EXPECT_THAT(Run({"HLEN", key}), IntArg(25));
549+
}
533550
}
534551

535552
} // namespace dfly

src/server/tiering/decoders.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44

55
#include "server/tiering/decoders.h"
66

7-
<<<<<<< HEAD
8-
#include "base/logging.h"
9-
=======
107
#include "core/compact_object.h"
11-
>>>>>>> fbcc8d59 (more than POc)
128
#include "core/detail/listpack_wrap.h"
9+
#include "core/overloaded.h"
1310
#include "server/tiering/serialized_map.h"
1411

1512
extern "C" {
@@ -82,8 +79,12 @@ void SerializedMapDecoder::Initialize(std::string_view slice) {
8279
}
8380

8481
Decoder::UploadMetrics SerializedMapDecoder::GetMetrics() const {
85-
return UploadMetrics{.modified = modified_,
86-
.estimated_mem_usage = map_->DataBytes() + map_->size() * 2 * 8};
82+
Overloaded ov{
83+
[](const SerializedMap& sm) { return sm.DataBytes() + sm.size() * 8; },
84+
[](const detail::ListpackWrap& lw) { return lw.DataBytes(); },
85+
};
86+
size_t bytes = visit(Overloaded{ov, [&](const auto& ptr) { return ov(*ptr); }}, map_);
87+
return UploadMetrics{.modified = modified_, .estimated_mem_usage = bytes};
8788
}
8889

8990
void SerializedMapDecoder::Upload(CompactObj* obj) {

0 commit comments

Comments
 (0)