mirror of https://github.com/tikv/client-go.git
fix the calculation of write request total write bytes (#691)
Signed-off-by: glorv <glorvs@163.com>
This commit is contained in:
parent
6a1ecaa292
commit
29dfcc2729
|
|
@ -16,7 +16,6 @@ package resourcecontrol
|
|||
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"github.com/pingcap/kvproto/pkg/coprocessor"
|
||||
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
||||
|
|
@ -43,9 +42,17 @@ func MakeRequestInfo(req *tikvrpc.Request) *RequestInfo {
|
|||
var writeBytes int64
|
||||
switch r := req.Req.(type) {
|
||||
case *kvrpcpb.PrewriteRequest:
|
||||
writeBytes += int64(r.TxnSize)
|
||||
for _, m := range r.Mutations {
|
||||
writeBytes += int64(len(m.Key)) + int64(len(m.Value))
|
||||
}
|
||||
writeBytes += int64(len(r.PrimaryLock))
|
||||
for _, l := range r.Secondaries {
|
||||
writeBytes += int64(len(l))
|
||||
}
|
||||
case *kvrpcpb.CommitRequest:
|
||||
writeBytes += int64(unsafe.Sizeof(r.Keys))
|
||||
for _, k := range r.Keys {
|
||||
writeBytes += int64(len(k))
|
||||
}
|
||||
}
|
||||
|
||||
return &RequestInfo{writeBytes: writeBytes}
|
||||
|
|
|
|||
Loading…
Reference in New Issue