You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 use GetNewChunkWithCapacity to allocate chunks from the allocator, and it'll use (*SessionVars).ChunkPool.mu to protect the allocator inside the BaseExecutor. It's reasonable because usually all BaseExecutor just used the ChunkPool in session context. However, just from the code, the relationship between the (*SessionVars).ChunkPool.mu and the BaseExecutor.Alloc is not significant.
We expect to remove session context from the BaseExecutor, so we have to remove the GetNewChunkWithCapacity function call in the implementation of BaseExecutor.
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.
The text was updated successfully, but these errors were encountered:
For this issue, I'm not going to rewrite chunk.(*allocator), but only refactor variable.ReuseChunkPool, which is used to re-use the same (*allocator) in a session across many different queries.
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.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.
The text was updated successfully, but these errors were encountered: