fix the calculation of write request total write bytes (#691)

Signed-off-by: glorv <glorvs@163.com>
This commit is contained in:
glorv 2023-02-07 17:07:54 +08:00 committed by GitHub
parent 6a1ecaa292
commit 29dfcc2729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -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}