Open markjenny opened 4 years ago
running the tiup playground on my laptop. 1 TiKV, 1 TiDB and 1 PD.
using sysbench to create one database consist of 32 tables. There're 10000 records in each table.
sysbench oltp_update_non_index --config-file=config --threads=32 --tables=32 --table-size=10000 prepare
generate the profile using the method below
curl http://{TiDBIP}:10080/debug/zip?seconds=60 --output debug.zip
the heap profile is here The most memory cost is in the fuction buildValueListOfInsert, So try to find the memory optimization.
buildValueListOfInsert
In the file initialize.go, there are some Init function using the value receiver, like this:
initialize.go
// Init initializes Delete. func (p Delete) Init(ctx sessionctx.Context) *Delete { p.basePlan = newBasePlan(ctx, plancodec.TypeDelete, 0) return &p } // Init initializes Insert. func (p Insert) Init(ctx sessionctx.Context) *Insert { p.basePlan = newBasePlan(ctx, plancodec.TypeInsert, 0) return &p }
We can use the pointer receiver to finish the same init as the value receiver using the below code. And there is no need of value copy, costing less memory. copy
// Init initializes Insert. func (p *Insert) Init(ctx sessionctx.Context) *Insert { p.basePlan = newBasePlan(ctx, plancodec.TypeInsert, 0) return p }
/label type/suggestion
/label status/PTAL
/label sig/planner
topology
running the tiup playground on my laptop. 1 TiKV, 1 TiDB and 1 PD.
workload
using sysbench to create one database consist of 32 tables. There're 10000 records in each table.
profile
generate the profile using the method below
the heap profile is here The most memory cost is in the fuction
buildValueListOfInsert
, So try to find the memory optimization.In the file
initialize.go
, there are some Init function using the value receiver, like this:We can use the pointer receiver to finish the same init as the value receiver using the below code. And there is no need of value copy, costing less memory. copy