From d4c5f954f7ed409f22985a5d05ac30883da9a323 Mon Sep 17 00:00:00 2001 From: simonjoylet Date: Mon, 6 Feb 2023 15:59:56 +0800 Subject: [PATCH] use arena allocator for btree node --- src/storage/ddl/ob_tablet_ddl_kv.cpp | 8 ++++---- src/storage/ddl/ob_tablet_ddl_kv.h | 2 +- unittest/storage/ddl/test_ddl_kv.cpp | 3 --- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/storage/ddl/ob_tablet_ddl_kv.cpp b/src/storage/ddl/ob_tablet_ddl_kv.cpp index a7447cb275..80ad4c1c8f 100644 --- a/src/storage/ddl/ob_tablet_ddl_kv.cpp +++ b/src/storage/ddl/ob_tablet_ddl_kv.cpp @@ -39,7 +39,7 @@ using namespace oceanbase::share::schema; ObBlockMetaTree::ObBlockMetaTree() - : is_inited_(false), fifo_allocator_(), tree_allocator_(fifo_allocator_), block_tree_(tree_allocator_) + : is_inited_(false), arena_(), tree_allocator_(arena_), block_tree_(tree_allocator_) { } @@ -62,8 +62,7 @@ int ObBlockMetaTree::init(const share::ObLSID &ls_id, } else if (OB_UNLIKELY(!ls_id.is_valid() || !table_key.is_valid() || cluster_version <= 0)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(table_key)); - } else if (OB_FAIL(fifo_allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE, mem_attr))) { - LOG_WARN("init fifo allocator failed", K(ret)); + } else if (FALSE_IT(arena_.set_attr(mem_attr))) { } else if (OB_FAIL(block_tree_.init())) { LOG_WARN("init block tree failed", K(ret)); } else if (OB_FAIL(ObTabletDDLUtil::prepare_index_data_desc(ls_id, @@ -160,7 +159,8 @@ void ObBlockMetaTree::destroy() block_tree_.destroy(); data_desc_.reset(); sorted_rowkeys_.reset(); - fifo_allocator_.reset(); + tree_allocator_.reset(); + arena_.reset(); } int ObBlockMetaTree::insert_macro_block(const ObDDLMacroHandle ¯o_handle, diff --git a/src/storage/ddl/ob_tablet_ddl_kv.h b/src/storage/ddl/ob_tablet_ddl_kv.h index 8b1deff59d..d1346b4eb1 100644 --- a/src/storage/ddl/ob_tablet_ddl_kv.h +++ b/src/storage/ddl/ob_tablet_ddl_kv.h @@ -98,7 +98,7 @@ private: private: bool is_inited_; ObArray macro_blocks_; - ObFIFOAllocator fifo_allocator_; + ObArenaAllocator arena_; BtreeNodeAllocator tree_allocator_; KeyBtree block_tree_; blocksstable::ObDataStoreDesc data_desc_; diff --git a/unittest/storage/ddl/test_ddl_kv.cpp b/unittest/storage/ddl/test_ddl_kv.cpp index 0aa276e68f..80214008a0 100644 --- a/unittest/storage/ddl/test_ddl_kv.cpp +++ b/unittest/storage/ddl/test_ddl_kv.cpp @@ -132,9 +132,6 @@ void TestBlockMetaTree::prepare_schema() TEST_F(TestBlockMetaTree, random_keybtree) { ObBlockMetaTree meta_tree; - ObArenaAllocator arena; - const ObMemAttr mem_attr(TEST_TENANT_ID, "DDL_KV"); - ASSERT_OK(meta_tree.fifo_allocator_.init(&arena, OB_MALLOC_MIDDLE_BLOCK_SIZE, mem_attr)); LOG_INFO("wenqu debug: check size", "sizeof(BtreeNode)", sizeof(keybtree::BtreeNode),