xinyiZzz commented on PR #11040:
URL: https://github.com/apache/doris/pull/11040#issuecomment-1190122477

   refer this
   
   diff --git a/be/src/runtime/memory/chunk_allocator.cpp 
b/be/src/runtime/memory/chunk_allocator.cpp
   index 6db98ecc9..e69b4c2e8 100644
   --- a/be/src/runtime/memory/chunk_allocator.cpp
   +++ b/be/src/runtime/memory/chunk_allocator.cpp
   @@ -136,6 +136,8 @@ ChunkAllocator::ChunkAllocator(size_t reserve_limit)
    }
   
    Status ChunkAllocator::allocate(size_t size, Chunk* chunk) {
   +    DCHECK(BitUtil::RoundUpToPowerOfTwo(size) == size);
   +
        // fast path: allocate from current core arena
        int core_id = CpuInfo::get_current_core();
        chunk->size = size;
   diff --git a/be/src/runtime/memory/chunk_allocator.h 
b/be/src/runtime/memory/chunk_allocator.h
   index 43bd88444..fef62e6db 100644
   --- a/be/src/runtime/memory/chunk_allocator.h
   +++ b/be/src/runtime/memory/chunk_allocator.h
   @@ -62,11 +62,7 @@ public:
   
        ChunkAllocator(size_t reserve_limit);
   
   -    // Allocate a Chunk with a power-of-two length "size".
   -    // Return true if success and allocated chunk is saved in "chunk".
   -    // Otherwise return false.
   -    Status allocate(size_t size, Chunk* Chunk);
   -
   +    // Up size to 2^n length, allocate a chunk.
        Status allocate_align(size_t size, Chunk* chunk);
   
        // Free chunk allocated from this allocator
   @@ -78,6 +74,14 @@ public:
        // otherwise the capacity of chunk allocator will be wrong.
        void free(uint8_t* data, size_t size);
   
   +private:
   +    friend class MemPool;
   +
   +    // Allocate a Chunk with a power-of-two length "size".
   +    // Return true if success and allocated chunk is saved in "chunk".
   +    // Otherwise return false.
   +    Status allocate(size_t size, Chunk* Chunk);
   +
    private:
        static ChunkAllocator* _s_instance;


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to