add limit for replay allocator
This commit is contained in:
@ -35,19 +35,16 @@ ObTenantMutilAllocator::ObTenantMutilAllocator(uint64_t tenant_id)
|
||||
PALF_FETCH_LOG_TASK_SIZE(sizeof(palf::FetchLogTask)),
|
||||
LOG_IO_FLASHBACK_TASK_SIZE(sizeof(palf::LogIOFlashbackTask)),
|
||||
clog_blk_alloc_(),
|
||||
inner_table_replay_blk_alloc_(REPLAY_MEM_LIMIT_THRESHOLD * INNER_TABLE_REPLAY_MEM_PERCENT / 100),
|
||||
user_table_replay_blk_alloc_(REPLAY_MEM_LIMIT_THRESHOLD * (100 - INNER_TABLE_REPLAY_MEM_PERCENT) / 100),
|
||||
common_blk_alloc_(),
|
||||
unlimited_blk_alloc_(),
|
||||
replay_log_task_blk_alloc_(REPLAY_MEM_LIMIT_THRESHOLD),
|
||||
clog_ge_alloc_(ObMemAttr(tenant_id, ObModIds::OB_CLOG_GE), ObVSliceAlloc::DEFAULT_BLOCK_SIZE, clog_blk_alloc_),
|
||||
inner_table_replay_task_alloc_(ObMemAttr(tenant_id, ObModIds::OB_LOG_REPLAY_ENGINE), ObVSliceAlloc::DEFAULT_BLOCK_SIZE, inner_table_replay_blk_alloc_),
|
||||
user_table_replay_task_alloc_(ObMemAttr(tenant_id, ObModIds::OB_LOG_REPLAY_ENGINE), ObVSliceAlloc::DEFAULT_BLOCK_SIZE, user_table_replay_blk_alloc_),
|
||||
log_io_flush_log_task_alloc_(LOG_IO_FLUSH_LOG_TASK_SIZE, ObMemAttr(tenant_id, "FlushLog"), choose_blk_size(LOG_IO_FLUSH_LOG_TASK_SIZE), clog_blk_alloc_, this),
|
||||
log_io_truncate_log_task_alloc_(LOG_IO_TRUNCATE_LOG_TASK_SIZE, ObMemAttr(tenant_id, "TruncateLog"), choose_blk_size(LOG_IO_TRUNCATE_LOG_TASK_SIZE), clog_blk_alloc_, this),
|
||||
log_io_flush_meta_task_alloc_(LOG_IO_FLUSH_META_TASK_SIZE, ObMemAttr(tenant_id, "FlushMeta"), choose_blk_size(LOG_IO_FLUSH_META_TASK_SIZE), clog_blk_alloc_, this),
|
||||
log_io_truncate_prefix_blocks_task_alloc_(LOG_IO_TRUNCATE_PREFIX_BLOCKS_TASK_SIZE, ObMemAttr(tenant_id, "FlushMeta"), choose_blk_size(LOG_IO_TRUNCATE_PREFIX_BLOCKS_TASK_SIZE), clog_blk_alloc_, this),
|
||||
palf_fetch_log_task_alloc_(PALF_FETCH_LOG_TASK_SIZE, ObMemAttr(tenant_id, ObModIds::OB_FETCH_LOG_TASK), choose_blk_size(PALF_FETCH_LOG_TASK_SIZE), clog_blk_alloc_, this),
|
||||
replay_log_task_alloc_(ObMemAttr(tenant_id, ObModIds::OB_LOG_REPLAY_TASK), common::OB_MALLOC_BIG_BLOCK_SIZE),
|
||||
replay_log_task_alloc_(ObMemAttr(tenant_id, ObModIds::OB_LOG_REPLAY_TASK), common::OB_MALLOC_BIG_BLOCK_SIZE, replay_log_task_blk_alloc_),
|
||||
log_io_flashback_task_alloc_(LOG_IO_FLASHBACK_TASK_SIZE, ObMemAttr(tenant_id, "Flashback"), choose_blk_size(LOG_IO_FLASHBACK_TASK_SIZE), clog_blk_alloc_, this)
|
||||
{
|
||||
// set_nway according to tenant's max_cpu
|
||||
@ -79,8 +76,6 @@ int ObTenantMutilAllocator::choose_blk_size(int obj_size)
|
||||
void ObTenantMutilAllocator::try_purge()
|
||||
{
|
||||
clog_ge_alloc_.purge_extra_cached_block(0);
|
||||
inner_table_replay_task_alloc_.purge_extra_cached_block(0);
|
||||
user_table_replay_task_alloc_.purge_extra_cached_block(0);
|
||||
log_io_flush_log_task_alloc_.purge_extra_cached_block(0);
|
||||
log_io_truncate_log_task_alloc_.purge_extra_cached_block(0);
|
||||
log_io_flush_meta_task_alloc_.purge_extra_cached_block(0);
|
||||
@ -122,43 +117,6 @@ const ObBlockAllocMgr &ObTenantMutilAllocator::get_clog_blk_alloc_mgr() const
|
||||
return clog_blk_alloc_;
|
||||
}
|
||||
|
||||
void *ObTenantMutilAllocator::alloc_replay_task_buf(const bool is_inner_table, const int64_t size)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
ObVSliceAlloc &allocator = is_inner_table ? inner_table_replay_task_alloc_ : user_table_replay_task_alloc_;
|
||||
ptr = allocator.alloc(size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void ObTenantMutilAllocator::free_replay_task(const bool is_inner_table, void *ptr)
|
||||
{
|
||||
if (OB_LIKELY(NULL != ptr)) {
|
||||
ObVSliceAlloc &allocator = is_inner_table ? inner_table_replay_task_alloc_ : user_table_replay_task_alloc_;
|
||||
allocator.free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
bool ObTenantMutilAllocator::can_alloc_replay_task(const bool is_inner_table, int64_t size) const
|
||||
{
|
||||
const ObVSliceAlloc &allocator = is_inner_table ? inner_table_replay_task_alloc_ : user_table_replay_task_alloc_;
|
||||
return allocator.can_alloc_block(size);
|
||||
}
|
||||
|
||||
void ObTenantMutilAllocator::inc_pending_replay_mutator_size(int64_t size)
|
||||
{
|
||||
ATOMIC_AAF(&pending_replay_mutator_size_, size);
|
||||
}
|
||||
|
||||
void ObTenantMutilAllocator::dec_pending_replay_mutator_size(int64_t size)
|
||||
{
|
||||
ATOMIC_SAF(&pending_replay_mutator_size_, size);
|
||||
}
|
||||
|
||||
int64_t ObTenantMutilAllocator::get_pending_replay_mutator_size() const
|
||||
{
|
||||
return ATOMIC_LOAD(&pending_replay_mutator_size_);
|
||||
}
|
||||
|
||||
LogIOFlushLogTask *ObTenantMutilAllocator::alloc_log_io_flush_log_task(
|
||||
const int64_t palf_id, const int64_t palf_epoch)
|
||||
{
|
||||
@ -304,8 +262,6 @@ void ObTenantMutilAllocator::set_nway(const int32_t nway)
|
||||
{
|
||||
if (nway > 0) {
|
||||
clog_ge_alloc_.set_nway(nway);
|
||||
inner_table_replay_task_alloc_.set_nway(nway);
|
||||
user_table_replay_task_alloc_.set_nway(nway);
|
||||
OB_LOG(INFO, "finish set nway", K(tenant_id_), K(nway));
|
||||
}
|
||||
}
|
||||
@ -316,15 +272,12 @@ void ObTenantMutilAllocator::set_limit(const int64_t total_limit)
|
||||
ATOMIC_STORE(&total_limit_, total_limit);
|
||||
const int64_t clog_limit = total_limit / 100 * CLOG_MEM_LIMIT_PERCENT;
|
||||
const int64_t replay_limit = std::min(total_limit / 100 * REPLAY_MEM_LIMIT_PERCENT, REPLAY_MEM_LIMIT_THRESHOLD);
|
||||
const int64_t inner_table_replay_limit = replay_limit * INNER_TABLE_REPLAY_MEM_PERCENT / 100;
|
||||
const int64_t user_table_replay_limit = replay_limit * (100 - INNER_TABLE_REPLAY_MEM_PERCENT) / 100;
|
||||
const int64_t common_limit = total_limit - (clog_limit + replay_limit);
|
||||
clog_blk_alloc_.set_limit(clog_limit);
|
||||
inner_table_replay_blk_alloc_.set_limit(inner_table_replay_limit);
|
||||
user_table_replay_blk_alloc_.set_limit(user_table_replay_limit);
|
||||
common_blk_alloc_.set_limit(common_limit);
|
||||
replay_log_task_alloc_.set_limit(replay_limit);
|
||||
OB_LOG(INFO, "ObTenantMutilAllocator set tenant mem limit finished", K(tenant_id_), K(total_limit), K(clog_limit),
|
||||
K(replay_limit), K(common_limit), K(inner_table_replay_limit), K(user_table_replay_limit));
|
||||
K(replay_limit), K(common_limit));
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,8 +288,8 @@ int64_t ObTenantMutilAllocator::get_limit() const
|
||||
|
||||
int64_t ObTenantMutilAllocator::get_hold() const
|
||||
{
|
||||
return clog_blk_alloc_.hold() + inner_table_replay_blk_alloc_.hold()
|
||||
+ user_table_replay_blk_alloc_.hold() + common_blk_alloc_.hold();
|
||||
return clog_blk_alloc_.hold() + common_blk_alloc_.hold()
|
||||
+ replay_log_task_blk_alloc_.hold();
|
||||
}
|
||||
|
||||
#define SLICE_FREE_OBJ(name, cls) \
|
||||
|
||||
Reference in New Issue
Block a user