TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
To reduce object allocation in the point get, I aggressively reuse the objects.
When I try to reuse the StatementContext in https://github.com/pingcap/tidb/pull/26007, I found some problem.
In the past, SetProcessInfo() get a snapshot of the process info:
This is a shallow copy, when ResetContextStmt() create objects, the pi referred objects are never touched again.
But if I reuse those object, the pi will be modified too! It's not a real snapshot any more.
So we can not reuse the old StmtCtx is the a new statement .... the pi is still referencing it.
Hmm, I think the PR could be reopened after solving the issue. My first idea is to provide a Clone for StmtCtx, and remove RuntimeStatsColl in the processinfo.
Enhancement
To reduce object allocation in the point get, I aggressively reuse the objects. When I try to reuse the
StatementContext
in https://github.com/pingcap/tidb/pull/26007, I found some problem.In the past,
SetProcessInfo()
get a snapshot of the process info:This is a shallow copy, when
ResetContextStmt()
create objects, thepi
referred objects are never touched again. But if I reuse those object, thepi
will be modified too! It's not a real snapshot any more.So we can not reuse the old
StmtCtx
is the a new statement .... thepi
is still referencing it.