Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/core/compact_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,13 @@ CompactObj::ExternalRep CompactObj::GetExternalRep() const {
return static_cast<CompactObj::ExternalRep>(u_.ext_ptr.representation);
}

void CompactObj::SetCool(size_t offset, uint32_t sz, detail::TieredColdRecord* record) {
void CompactObj::SetCool(size_t offset, uint32_t sz, ExternalRep rep,
detail::TieredColdRecord* record) {
// We copy the mask of the "cooled" referenced object because it contains the encoding info.
SetMeta(EXTERNAL_TAG, record->value.mask_);

u_.ext_ptr.is_cool = 1;
u_.ext_ptr.representation = static_cast<uint8_t>(rep);
u_.ext_ptr.page_offset = offset % 4096;
u_.ext_ptr.serialized_size = sz;
u_.ext_ptr.cool_record = record;
Expand All @@ -1244,6 +1246,10 @@ auto CompactObj::GetCool() const -> CoolItem {
return res;
}

void CompactObj::Freeze(size_t offset, size_t sz) {
SetExternal(offset, sz, GetExternalRep());
}

std::pair<size_t, size_t> CompactObj::GetExternalSlice() const {
DCHECK_EQ(EXTERNAL_TAG, taglen_);
auto& ext = u_.ext_ptr;
Expand Down Expand Up @@ -1614,7 +1620,7 @@ StringOrView CompactObj::GetRawString() const {
return StringOrView::FromString(std::move(tmp));
}

LOG(FATAL) << "Unsupported tag for GetRawString(): " << taglen_;
LOG(FATAL) << "Unsupported tag for GetRawString(): " << int(taglen_);
return {};
}

Expand Down
7 changes: 6 additions & 1 deletion src/core/compact_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ class CompactObj {
}

// Assigns a cooling record to the object together with its external slice.
void SetCool(size_t offset, uint32_t serialized_size, detail::TieredColdRecord* record);
void SetCool(size_t offset, uint32_t serialized_size, ExternalRep rep,
detail::TieredColdRecord* record);

struct CoolItem {
uint16_t page_offset;
Expand All @@ -376,6 +377,10 @@ class CompactObj {
// Returns the external data of the object incuding its ColdRecord.
CoolItem GetCool() const;

// Prequisite: IsCool() is true.
// Keeps cool record only as external value and discard in-memory part.
void Freeze(size_t offset, size_t sz);

std::pair<size_t, size_t> GetExternalSlice() const;

// Injects either the the raw string (extracted with GetRawString()) or the usual string
Expand Down
4 changes: 4 additions & 0 deletions src/core/detail/listpack_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ ListpackWrap::~ListpackWrap() {
DCHECK(!dirty_);
}

ListpackWrap ListpackWrap::WithCapacity(size_t capacity) {
return ListpackWrap{lpNew(capacity)};
}

uint8_t* ListpackWrap::GetPointer() {
dirty_ = false;
return lp_;
Expand Down
3 changes: 3 additions & 0 deletions src/core/detail/listpack_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ struct ListpackWrap {
explicit ListpackWrap(uint8_t* lp) : lp_{lp} {
}

// Create listpack with capacity
static ListpackWrap WithCapacity(size_t capacity);

uint8_t* GetPointer(); // Get new updated pointer
Iterator Find(std::string_view key) const; // Linear search
bool Delete(std::string_view key);
Expand Down
4 changes: 3 additions & 1 deletion src/server/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool ParseDouble(string_view src, double* value) {
#define ADD(x) (x) += o.x

TieredStats& TieredStats::operator+=(const TieredStats& o) {
static_assert(sizeof(TieredStats) == 160);
static_assert(sizeof(TieredStats) == 168);

ADD(total_stashes);
ADD(total_fetches);
Expand All @@ -182,6 +182,8 @@ TieredStats& TieredStats::operator+=(const TieredStats& o) {
ADD(small_bins_cnt);
ADD(small_bins_entries_cnt);
ADD(small_bins_filling_bytes);
ADD(small_bins_filling_entries_cnt);

ADD(total_stash_overflows);
ADD(cold_storage_bytes);
ADD(total_offloading_steps);
Expand Down
1 change: 1 addition & 0 deletions src/server/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct TieredStats {
uint64_t small_bins_cnt = 0;
uint64_t small_bins_entries_cnt = 0;
size_t small_bins_filling_bytes = 0;
size_t small_bins_filling_entries_cnt = 0;
size_t cold_storage_bytes = 0;

uint64_t clients_throttled = 0; // current number of throttled clients
Expand Down
3 changes: 3 additions & 0 deletions src/server/hset_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ OpResult<uint32_t> OpSet(const OpArgs& op_args, string_view key, CmdArgList valu

op_args.shard->search_indices()->AddDoc(key, op_args.db_cntx, pv);

if (auto* ts = op_args.shard->tiered_storage(); ts)
ts->TryStash(op_args.db_cntx.db_index, key, &pv);

return created;
}

Expand Down
Loading
Loading