1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

WIPWIPWIP

This commit is contained in:
shahar 2024-05-09 15:32:35 +03:00
parent 9f6b716b47
commit 585aeec45b
No known key found for this signature in database
GPG key ID: 2ED7F7EDC7FDCCA4
6 changed files with 18 additions and 7 deletions

View file

@ -12,7 +12,7 @@
#include "base/logging.h"
#include "core/segment_allocator.h"
extern "C" bool mi_heap_page_is_underutilized(mi_heap_t* heap, void* p, float ratio);
bool mi_heap_page_is_underutilized(mi_heap_t* heap, void* p, float ratio);
namespace dfly {
using namespace std;

View file

@ -1,7 +1,7 @@
option(REDIS_ZMALLOC_MI "Implement zmalloc layer using mimalloc allocator" ON)
if (REDIS_ZMALLOC_MI)
set(ZMALLOC_SRC "zmalloc_mi.c")
set(ZMALLOC_SRC "zmalloc_mi.cc")
set(ZMALLOC_DEPS "TRDP::mimalloc")
else()
set(ZMALLOC_SRC "zmalloc.c")

View file

@ -7,7 +7,9 @@
#include <string.h>
#include <unistd.h>
extern "C" {
#include "zmalloc.h"
}
__thread ssize_t zmalloc_used_memory_tl = 0;
__thread mi_heap_t* zmalloc_heap = NULL;
@ -147,7 +149,7 @@ bool heap_count_wasted_blocks(const mi_heap_t* heap, const mi_heap_area_t* area,
};
int zmalloc_get_allocator_info(size_t* allocated, size_t* active, size_t* resident) {
Sum_t sum = {0};
Sum_t sum = {0, 0};
mi_heap_visit_blocks(zmalloc_heap, false /* visit all blocks*/, heap_visit_cb, &sum);
*allocated = sum.allocated;
@ -172,7 +174,7 @@ int zmalloc_get_allocator_wasted_blocks(float ratio, size_t* allocated, size_t*
void init_zmalloc_threadlocal(void* heap) {
if (zmalloc_heap)
return;
zmalloc_heap = heap;
zmalloc_heap = (mi_heap_t*)heap;
}
int zmalloc_page_is_underutilized(void* ptr, float ratio) {

View file

@ -161,7 +161,11 @@ void DoPopulateBatch(string_view type, string_view prefix, size_t val_size, bool
crb.SetReplyMode(ReplyMode::NONE);
stub_tx->InitByArgs(local_cntx.conn_state.db_index, args_span);
sf->service().InvokeCmd(cid, args_span, &local_cntx);
try {
sf->service().InvokeCmd(cid, args_span, &local_cntx);
} catch (const bad_alloc& e) {
LOG(WARNING) << "Unable to complete DEBUG POPULATE due to out of memory";
}
}
local_cntx.Inject(nullptr);

View file

@ -541,7 +541,7 @@ bool StringValue::IsEmpty() const {
OpStatus SetCmd::Set(const SetParams& params, string_view key, string_view value) {
auto& db_slice = op_args_.shard->db_slice();
DCHECK(db_slice.IsDbValid(op_args_.db_cntx.db_index));
DCHECK(db_slice.IsDbValid(op_args_.db_cntx.db_index)) << op_args_.db_cntx.db_index;
VLOG(2) << "Set " << key << "(" << db_slice.shard_id() << ") ";
if (params.IsConditionalSet()) {

View file

@ -1284,7 +1284,12 @@ OpStatus Transaction::RunSquashedMultiCb(RunnableType cb) {
DCHECK_EQ(unique_shard_cnt_, 1u);
auto* shard = EngineShard::tlocal();
auto result = cb(this, shard);
RunnableResult result;
try {
result = cb(this, shard);
} catch (const bad_alloc& e) {
result = RunnableResult(OpStatus::OUT_OF_MEMORY);
}
shard->db_slice().OnCbFinish();
LogAutoJournalOnShard(shard, result);