[BUG.FIX] fix normal tablet buffer memory fragment
This commit is contained in:
parent
b729ca7979
commit
9bb5269c64
@ -17,6 +17,7 @@
|
||||
#define protected public
|
||||
#define private public
|
||||
|
||||
#include "lib/alloc/memory_dump.h"
|
||||
#include "storage/tablet/ob_tablet_persister.h"
|
||||
#include "storage/meta_mem/ob_tenant_meta_mem_mgr.h"
|
||||
#include "storage/meta_mem/ob_tablet_leak_checker.h"
|
||||
@ -1730,6 +1731,34 @@ TEST_F(TestTenantMetaMemMgr, test_show_limit)
|
||||
lib::set_tenant_memory_limit(MTL_ID(), before_tenant_mem);
|
||||
}
|
||||
|
||||
TEST_F(TestTenantMetaMemMgr, test_normal_tablet_buffer_fragment)
|
||||
{
|
||||
static const int64_t tablet_cnt = 155000;
|
||||
ObTabletHandle *tablets = new ObTabletHandle[tablet_cnt];
|
||||
const int64_t before_tenant_mem = lib::get_tenant_memory_limit(MTL_ID());
|
||||
const int64_t this_case_tenant_mem = 3 * 1024 * 1024 * 1024L; /* 3GB */
|
||||
lib::set_tenant_memory_limit(MTL_ID(), this_case_tenant_mem);
|
||||
for (int64_t i = 0; i < tablet_cnt; ++i) {
|
||||
ObTabletHandle tablet_handle;
|
||||
ASSERT_EQ(OB_SUCCESS, MTL(ObTenantMetaMemMgr *)->acquire_tablet(ObTabletPoolType::TP_NORMAL, tablets[i]));
|
||||
}
|
||||
ObMallocAllocator::get_instance()->print_tenant_memory_usage(MTL_ID());
|
||||
ObMemoryDump::get_instance().init();
|
||||
auto task = ObMemoryDump::get_instance().alloc_task();
|
||||
task->type_ = STAT_LABEL;
|
||||
ObMemoryDump::get_instance().push(task);
|
||||
usleep(1000000);
|
||||
ObTenantCtxAllocatorGuard ta = ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(MTL_ID(), ObCtxIds::META_OBJ_CTX_ID);
|
||||
double fragment_rate = 1.0 * (ta->get_hold() - ta->get_used()) / ta->get_hold();
|
||||
std::cout << "hold: " << ta->get_hold() << " used: " << ta->get_used() << " limit: " << ta->get_limit() << " fragment_rate: " << fragment_rate << std::endl;
|
||||
ASSERT_TRUE(fragment_rate < 0.04);
|
||||
for (int64_t i = 0; i < tablet_cnt; ++i) {
|
||||
tablets[i].reset();
|
||||
}
|
||||
delete [] tablets;
|
||||
lib::set_tenant_memory_limit(MTL_ID(), before_tenant_mem);
|
||||
}
|
||||
|
||||
} // end namespace storage
|
||||
} // end namespace oceanbase
|
||||
|
||||
|
@ -122,7 +122,7 @@ class ObTenantMetaMemMgr final
|
||||
{
|
||||
public:
|
||||
static const int64_t THE_SIZE_OF_HEADERS = sizeof(ObFIFOAllocator::NormalPageHeader) + sizeof(ObMetaObjBufferNode);
|
||||
static const int64_t NORMAL_TABLET_POOL_SIZE = (ABLOCK_SIZE - ABLOCK_HEADER_SIZE) / 2 - AOBJECT_META_SIZE - THE_SIZE_OF_HEADERS; // 3952B
|
||||
static const int64_t NORMAL_TABLET_POOL_SIZE = (ABLOCK_SIZE - ABLOCK_HEADER_SIZE) / 2 - AOBJECT_META_SIZE - AOBJECT_EXTRA_INFO_SIZE - THE_SIZE_OF_HEADERS; // 3824B
|
||||
static const int64_t LARGE_TABLET_POOL_SIZE = 64 * 1024L - THE_SIZE_OF_HEADERS; // 65,480B
|
||||
|
||||
static const int64_t MIN_MODE_MAX_TABLET_CNT_IN_OBJ_POOL = 10000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user