diff --git a/src/storage/blocksstable/encoding/ob_encoding_allocator.h b/src/storage/blocksstable/encoding/ob_encoding_allocator.h index 9a3a162ab7..9c3691bd98 100644 --- a/src/storage/blocksstable/encoding/ob_encoding_allocator.h +++ b/src/storage/blocksstable/encoding/ob_encoding_allocator.h @@ -47,7 +47,7 @@ template struct ObEncodingPool { static const int64_t MAX_FREE_ITEM_CNT = 64; - ObEncodingPool(const int64_t item_size, const char *label); + ObEncodingPool(const int64_t item_size, const ObMemAttr &attr); ~ObEncodingPool(); template @@ -67,7 +67,7 @@ class ObEncodingAllocator { public: typedef ObEncodingPool Pool; - ObEncodingAllocator(const int64_t *size_array, const char *label); + ObEncodingAllocator(const int64_t *size_array, const ObMemAttr &attr); virtual ~ObEncodingAllocator() {} int init(); bool is_inited() const { return inited_; } @@ -104,11 +104,9 @@ public: allocator_(nullptr) { int ret = OB_SUCCESS; - lib::ObMemAttr attr; - attr.label_ = "encoding_alloc"; - SET_USE_500(attr); + lib::ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderAlloc"); if (nullptr == (allocator_ = OB_NEW(ObDecoderAllocator, attr, - decoder_sizes, "encoding_alloc"))) { + decoder_sizes, attr))) { ret = common::OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "allocate ObDecoderAllocator failed", K(ret)); } else if (OB_FAIL(allocator_->init())) { diff --git a/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp b/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp index b3e0822f31..e9ffc7cbc8 100644 --- a/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp +++ b/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp @@ -11,10 +11,10 @@ */ template -ObEncodingPool::ObEncodingPool(const int64_t item_size, const char *label) +ObEncodingPool::ObEncodingPool(const int64_t item_size, const ObMemAttr &attr) : free_items_(), free_cnt_(0), pool_(item_size, common::OB_MALLOC_NORMAL_BLOCK_SIZE, - common::ObMalloc(SET_USE_500(label))) + common::ObMalloc(attr)) { } @@ -66,19 +66,19 @@ inline void ObEncodingPool::free(EncodingItem *item) } template -ObEncodingAllocator::ObEncodingAllocator(const int64_t *size_array, const char *label) +ObEncodingAllocator::ObEncodingAllocator(const int64_t *size_array, const ObMemAttr &attr) : inited_(false), size_index_(0), - raw_pool_(size_array[size_index_++], label), - dict_pool_(size_array[size_index_++], label), - rle_pool_(size_array[size_index_++], label), - const_pool_(size_array[size_index_++], label), - int_diff_pool_(size_array[size_index_++], label), - str_diff_pool_(size_array[size_index_++], label), - hex_str_pool_(size_array[size_index_++], label), - str_prefix_pool_(size_array[size_index_++], label), - column_equal_pool_(size_array[size_index_++], label), - column_substr_pool_(size_array[size_index_++], label), + raw_pool_(size_array[size_index_++], attr), + dict_pool_(size_array[size_index_++], attr), + rle_pool_(size_array[size_index_++], attr), + const_pool_(size_array[size_index_++], attr), + int_diff_pool_(size_array[size_index_++], attr), + str_diff_pool_(size_array[size_index_++], attr), + hex_str_pool_(size_array[size_index_++], attr), + str_prefix_pool_(size_array[size_index_++], attr), + column_equal_pool_(size_array[size_index_++], attr), + column_substr_pool_(size_array[size_index_++], attr), pool_cnt_(0) { for (int64_t i = 0; i < ObColumnHeader::MAX_TYPE; i++) { diff --git a/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp b/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp index cf41c70bfd..d26dd23f3c 100644 --- a/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp +++ b/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp @@ -72,13 +72,15 @@ public: typedef ObColumnDecoderCtx ObDecoderCtx; ObDecoderCtxArray() : ctxs_() { - ctxs_.set_attr(SET_USE_500("DecoderCtxArray")); + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtxArr"); + ctxs_.set_attr(attr); }; virtual ~ObDecoderCtxArray() { + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtx"); FOREACH(it, ctxs_) { ObDecoderCtx *c = *it; - OB_DELETE(ObDecoderCtx, "TLDecoderCtx", c); + OB_DELETE(ObDecoderCtx, attr, c); } ctxs_.reset(); } @@ -93,15 +95,16 @@ public: ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret)); } else { + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtx"); if (ctxs_.count() < size) { for (int64_t i = ctxs_.count(); OB_SUCC(ret) && i < size; ++i) { - ObDecoderCtx *ctx = OB_NEW(ObDecoderCtx, "TLDecoderCtx"); + ObDecoderCtx *ctx = OB_NEW(ObDecoderCtx, attr); if (NULL == ctx) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); } else if (OB_FAIL(ctxs_.push_back(ctx))) { LOG_WARN("array push back failed", K(ret)); - OB_DELETE(ObDecoderCtx, "TLDecoderCtx", ctx); + OB_DELETE(ObDecoderCtx, attr, ctx); } } if (OB_SUCC(ret)) { @@ -129,14 +132,16 @@ class ObTLDecoderCtxArray public: ObTLDecoderCtxArray() : ctxs_array_() { - ctxs_array_.set_attr(SET_USE_500("TLDecoderCtxArr")); + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtxArr"); + ctxs_array_.set_attr(attr); } virtual ~ObTLDecoderCtxArray() { + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtx"); FOREACH(it, ctxs_array_) { ObDecoderCtxArray *ctxs = *it; - OB_DELETE(ObDecoderCtxArray, "TLDecoderCtx", ctxs); + OB_DELETE(ObDecoderCtxArray, attr, ctxs); } } @@ -149,7 +154,8 @@ public: ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("NULL instance", K(ret)); } else if (tl_array->ctxs_array_.empty()) { - ctxs = OB_NEW(ObDecoderCtxArray, "TLDecoderCtx"); + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtx"); + ctxs = OB_NEW(ObDecoderCtxArray, attr); if (NULL == ctxs) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); @@ -164,6 +170,7 @@ public: static void free(ObDecoderCtxArray *ctxs) { int ret = OB_SUCCESS; + ObMemAttr attr(ob_thread_tenant_id(), "TLDecoderCtx"); ObTLDecoderCtxArray *tl_array = instance(); if (NULL == tl_array) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -172,10 +179,10 @@ public: // do nothing } else if (tl_array->ctxs_array_.count() >= MAX_ARRAY_CNT) { // reach the threshold, release memory - OB_DELETE(ObDecoderCtxArray, "TLDecoderCtx", ctxs); + OB_DELETE(ObDecoderCtxArray, attr, ctxs); } else if (OB_FAIL(tl_array->ctxs_array_.push_back(ctxs))) { LOG_WARN("array push back failed", K(ret)); - OB_DELETE(ObDecoderCtxArray, "TLDecoderCtx", ctxs); + OB_DELETE(ObDecoderCtxArray, attr, ctxs); } } diff --git a/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp b/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp index a8759a2884..884abab73f 100644 --- a/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp +++ b/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp @@ -97,7 +97,7 @@ ObMicroBlockEncoder::ObMicroBlockEncoder() : ctx_(), header_(NULL), buffered_rows_checksum_(0), estimate_size_(0), estimate_size_limit_(0), header_size_(0), expand_pct_(DEFAULT_ESTIMATE_REAL_SIZE_PCT), row_buf_holder_(blocksstable::OB_ENCODING_LABEL_ROW_BUFFER, OB_MALLOC_MIDDLE_BLOCK_SIZE), - encoder_allocator_(encoder_sizes, common::ObModIds::OB_ENCODER_ALLOCATOR), + encoder_allocator_(encoder_sizes, ObMemAttr(MTL_ID(), common::ObModIds::OB_ENCODER_ALLOCATOR)), string_col_cnt_(0), estimate_base_store_size_(0), length_(0), is_inited_(false) {