@@ -18,7 +18,6 @@ import (
18
18
"time"
19
19
"unsafe"
20
20
21
- "github.com/pingcap/tidb/pkg/metrics"
22
21
"github.com/pingcap/tidb/pkg/parser"
23
22
"github.com/pingcap/tidb/pkg/parser/ast"
24
23
"github.com/pingcap/tidb/pkg/sessionctx"
@@ -224,47 +223,8 @@ func (br Bindings) size() float64 {
224
223
return mem
225
224
}
226
225
227
- var statusIndex = map [string ]int {
228
- Enabled : 0 ,
229
- deleted : 1 ,
230
- Invalid : 2 ,
231
- }
232
-
233
- func bindingMetrics (br Bindings ) ([]float64 , []int ) {
234
- sizes := make ([]float64 , len (statusIndex ))
235
- count := make ([]int , len (statusIndex ))
236
- if br == nil {
237
- return sizes , count
238
- }
239
- commonLength := float64 (0 )
240
- // We treat it as deleted if there are no bindings. It could only occur in session handles.
241
- if len (br ) == 0 {
242
- sizes [statusIndex [deleted ]] = commonLength
243
- count [statusIndex [deleted ]] = 1
244
- return sizes , count
245
- }
246
- // Make the common length counted in the first binding.
247
- sizes [statusIndex [br [0 ].Status ]] = commonLength
248
- for _ , binding := range br {
249
- sizes [statusIndex [binding.Status ]] += binding .size ()
250
- count [statusIndex [binding.Status ]]++
251
- }
252
- return sizes , count
253
- }
254
-
255
226
// size calculates the memory size of a bind info.
256
227
func (b * Binding ) size () float64 {
257
228
res := len (b .OriginalSQL ) + len (b .Db ) + len (b .BindSQL ) + len (b .Status ) + 2 * int (unsafe .Sizeof (b .CreateTime )) + len (b .Charset ) + len (b .Collation ) + len (b .ID )
258
229
return float64 (res )
259
230
}
260
-
261
- func updateMetrics (scope string , before Bindings , after Bindings , sizeOnly bool ) {
262
- beforeSize , beforeCount := bindingMetrics (before )
263
- afterSize , afterCount := bindingMetrics (after )
264
- for status , index := range statusIndex {
265
- metrics .BindMemoryUsage .WithLabelValues (scope , status ).Add (afterSize [index ] - beforeSize [index ])
266
- if ! sizeOnly {
267
- metrics .BindTotalGauge .WithLabelValues (scope , status ).Add (float64 (afterCount [index ] - beforeCount [index ]))
268
- }
269
- }
270
- }
0 commit comments