[BUG.FIX] Reduce lock conflicts

This commit is contained in:
Tyshawn 2022-11-07 04:38:13 +00:00 committed by wangzelin.wzl
parent 55f776959e
commit f61b55b314
3 changed files with 8 additions and 4 deletions

View File

@ -130,15 +130,20 @@ int ObTenantMetaMemMgr::init()
{
int ret = OB_SUCCESS;
lib::ObMemAttr mem_attr(tenant_id_, "MetaAllocator", ObCtxIds::META_OBJ_CTX_ID);
const int64_t mem_limit = get_tenant_memory_limit(tenant_id_);
const int64_t min_bkt_cnt = DEFAULT_BUCKET_NUM;
const int64_t max_bkt_cnt = 10000000L;
const int64_t tablet_bucket_num = std::min(std::max((mem_limit / (1024 * 1024 * 1024)) * 50000, min_bkt_cnt), max_bkt_cnt);
const int64_t bucket_num = common::hash::cal_next_prime(tablet_bucket_num);
if (OB_UNLIKELY(is_inited_)) {
ret = OB_INIT_TWICE;
LOG_WARN("ObTenantMetaMemMgr has been initialized", K(ret));
} else if (OB_FAIL(bucket_lock_.init(DEFAULT_LOCK_BUCKET_COUNT, ObLatchIds::BLOCK_MANAGER_LOCK))) {
} else if (OB_FAIL(bucket_lock_.init(bucket_num, ObLatchIds::BLOCK_MANAGER_LOCK))) {
LOG_WARN("fail to init bucket lock", K(ret));
} else if (OB_FAIL(allocator_.init(lib::ObMallocAllocator::get_instance(),
OB_MALLOC_NORMAL_BLOCK_SIZE, mem_attr))) {
LOG_WARN("fail to init tenant fifo allocator", K(ret));
} else if (OB_FAIL(tablet_map_.init(DEFAULT_BUCKET_NUM, "TabletMap", TOTAL_LIMIT, HOLD_LIMIT,
} else if (OB_FAIL(tablet_map_.init(bucket_num, "TabletMap", TOTAL_LIMIT, HOLD_LIMIT,
common::OB_MALLOC_NORMAL_BLOCK_SIZE))) {
LOG_WARN("fail to initialize tablet map", K(ret));
} else if (OB_FAIL(last_min_minor_sstable_set_.create(DEFAULT_MINOR_SSTABLE_SET_COUNT))) {

View File

@ -90,7 +90,6 @@ private:
static const int64_t MAX_TABLET_CNT_IN_OBJ_POOL = 50000;
static const int64_t MAX_SSTABLE_CNT_IN_OBJ_POOL = 5 * MAX_TABLET_CNT_IN_OBJ_POOL;
static const int64_t MAX_MEMTABLE_CNT_IN_OBJ_POOL = 2 * MAX_TABLET_CNT_IN_OBJ_POOL;
static const int64_t DEFAULT_LOCK_BUCKET_COUNT = 2048;
static const int64_t MAX_TX_DATA_MEMTABLE_CNT_IN_OBJ_POOL = MAX_MEMSTORE_CNT * OB_MINI_MODE_MAX_LS_NUM_PER_TENANT_PER_SERVER;
static const int64_t MAX_TX_CTX_MEMTABLE_CNT_IN_OBJ_POOL = OB_MINI_MODE_MAX_LS_NUM_PER_TENANT_PER_SERVER;
static const int64_t MAX_LOCK_MEMTABLE_CNT_IN_OBJ_POOL = OB_MINI_MODE_MAX_LS_NUM_PER_TENANT_PER_SERVER;

View File

@ -66,7 +66,7 @@ TestMetaPointerMap::TestMetaPointerMap()
void TestMetaPointerMap::SetUp()
{
int ret = tablet_map_.init(10243L, "TabletMap", 15 * 1024L * 1024L * 1024L, 8 * 1024L * 1024L,
int ret = tablet_map_.init(100000000L, "TabletMap", 15 * 1024L * 1024L * 1024L, 8 * 1024L * 1024L,
common::OB_MALLOC_NORMAL_BLOCK_SIZE);
ASSERT_EQ(common::OB_SUCCESS, ret);