Skip to content

Commit abde632

Browse files
committed
tmp
Signed-off-by: Vladislav Oleshko <[email protected]>
1 parent 9303f27 commit abde632

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
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 & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,8 @@ bool TieredStorage::ShouldStash(const PrimeValue& pv) const {
706706
}
707707

708708
void TieredStorage::CoolDown(DbIndex db_ind, std::string_view str,
709-
<<<<<<< HEAD
710709
const tiering::DiskSegment& segment, CompactObj::ExternalRep rep,
711710
PrimeValue* pv) {
712-
=======
713-
const tiering::DiskSegment& segment, PrimeValue* pv,
714-
CompactObj::ExternalRep rep) {
715-
>>>>>>> 5b1ceb13 (cooling fixes)
716711
detail::TieredColdRecord* record = CompactObj::AllocateMR<detail::TieredColdRecord>();
717712
cool_queue_.push_front(*record);
718713
stats_.cool_memory_used += (sizeof(detail::TieredColdRecord) + pv->MallocUsed());
@@ -722,11 +717,7 @@ void TieredStorage::CoolDown(DbIndex db_ind, std::string_view str,
722717
record->page_index = segment.offset / tiering::kPageSize;
723718
record->value = std::move(*pv);
724719

725-
<<<<<<< HEAD
726720
pv->SetCool(segment.offset, segment.length, rep, record);
727-
=======
728-
pv->SetCool(segment.offset, segment.length, record, rep);
729-
>>>>>>> 5b1ceb13 (cooling fixes)
730721
}
731722

732723
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)