Skip to content
Merged
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
14 changes: 3 additions & 11 deletions src/core/compact_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,6 @@ class CompactObj {

bool DefragIfNeeded(PageUsage* page_usage);

void SetAsyncDelete() {
mask_bits_.io_pending = 1; // io_pending flag is used for async delete for keys.
}

bool IsAsyncDelete() const {
return mask_bits_.io_pending;
}

bool HasStashPending() const {
return mask_bits_.io_pending;
}
Expand Down Expand Up @@ -542,16 +534,16 @@ class CompactObj {
union {
uint8_t mask_ = 0;
struct {
uint8_t ref : 1; // Mark objects that have expiry timestamp assigned.
uint8_t expire : 1;
uint8_t ref : 1; // Mark objects that don't own their allocation.
uint8_t expire : 1; // Mark objects that have expiry timestamp assigned.
uint8_t mc_flag : 1; // Marks keys that have memcache flags assigned.

// See the EncodingEnum for the meaning of these bits.
uint8_t encoding : 2;

// IO_PENDING is set when the tiered storage has issued an i/o request to save the value.
// It is cleared when the io request finishes or is cancelled.
uint8_t io_pending : 1; // also serves as async-delete for keys.
uint8_t io_pending : 1;
uint8_t sticky : 1;

// TOUCHED used to determin which items are hot/cold.
Expand Down
10 changes: 5 additions & 5 deletions src/server/db_slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ void DbSlice::ActivateDb(DbIndex db_ind) {
CreateDb(db_ind);
}

void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table) {
void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table, bool async) {
CHECK(IsValid(it));

ExpIterator exp_it;
Expand All @@ -820,7 +820,7 @@ void DbSlice::Del(Context cntx, Iterator it, DbTable* db_table) {
DCHECK(!exp_it.is_done());
}

PerformDeletionAtomic(it, exp_it, table);
PerformDeletionAtomic(it, exp_it, table, async);
}

void DbSlice::DelMutable(Context cntx, ItAndUpdater it_updater) {
Expand Down Expand Up @@ -1771,7 +1771,7 @@ unique_ptr<base::Histogram> DbSlice::StopSampleValues(DbIndex db_ind) {
}

void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it,
DbTable* table) {
DbTable* table, bool async) {
FiberAtomicGuard guard;
size_t table_before = table->table_memory();
if (!exp_it.is_done()) {
Expand Down Expand Up @@ -1804,7 +1804,7 @@ void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& e
}
AccountObjectMemory(del_it.key(), pv.ObjType(), -value_heap_size, table); // Value

if (del_it->first.IsAsyncDelete() && MayDeleteAsynchronously(pv)) {
if (async && MayDeleteAsynchronously(pv)) {
DenseSet* ds = (DenseSet*)pv.RObjPtr();
pv.SetRObjPtr(nullptr);
const size_t kClearStepSize = 512;
Expand All @@ -1815,7 +1815,7 @@ void DbSlice::PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& e
} else {
CompactObj::DeleteMR<DenseSet>(ds);
}
} // del_it->first.IsAsyncDelete()
}

if (table->slots_stats) {
SlotId sid = KeySlot(del_it.key());
Expand Down
6 changes: 4 additions & 2 deletions src/server/db_slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ class DbSlice {
// Deletes the iterator. The iterator must be valid.
// Context argument is used only for document removal and it just needs
// timestamp field. Last argument, db_table, is optional and is used only in FlushSlotsCb.
void Del(Context cntx, Iterator it, DbTable* db_table = nullptr);
// If async is set, AsyncDeleter will enqueue deletion of the object
void Del(Context cntx, Iterator it, DbTable* db_table = nullptr, bool async = false);

// Deletes a key after FindMutable(). Runs post_updater before deletion
// to update memory accounting while the key is still valid.
Expand Down Expand Up @@ -571,7 +572,8 @@ class DbSlice {
void RemoveOffloadedEntriesFromTieredStorage(absl::Span<const DbIndex> indices,
const DbTableArray& db_arr) const;

void PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, DbTable* table);
void PerformDeletionAtomic(const Iterator& del_it, const ExpIterator& exp_it, DbTable* table,
bool async = false);

// Queues invalidation message to the clients that are tracking the change to a key.
void QueueInvalidationTrackingMessageAtomic(std::string_view key);
Expand Down
5 changes: 1 addition & 4 deletions src/server/generic_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,7 @@ OpResult<uint32_t> GenericFamily::OpDel(const OpArgs& op_args, const ShardArgs&
if (!IsValid(it))
continue;

if (async)
it->first.SetAsyncDelete();

db_slice.Del(op_args.db_cntx, it);
db_slice.Del(op_args.db_cntx, it, nullptr, async);
++res;
}

Expand Down
Loading