-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
Sometimes, we re-used the chunk pool to avoid re-allocating memories across multiple statements. This chunk pool located in the "connection", and is set into session context when it's possible to re-use the allocator. This part of code is quite confusing:
chunk.Allocator
is not safe to call concurrently. Therefore, we always useGetNewChunkWithCapacity
to allocate chunks from the allocator, and it'll use(*SessionVars).ChunkPool.mu
to protect the allocator inside theBaseExecutor
. It's reasonable because usually allBaseExecutor
just used theChunkPool
in session context. However, just from the code, the relationship between the(*SessionVars).ChunkPool.mu
and theBaseExecutor.Alloc
is not significant.- We expect to remove session context from the
BaseExecutor
, so we have to remove theGetNewChunkWithCapacity
function call in the implementation ofBaseExecutor
.
And also, we'll need to use a session variable to tell whether the re-use chunk pool optimization is enabled. Also, we have a read-only session variable to tell the users whether last statement used the re-used chunk 🤦 . It's a little complicated.
Metadata
Metadata
Assignees
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.