Skip to content

Commit

Permalink
fix the calculation of write request total write bytes (#691)
Browse files Browse the repository at this point in the history
Signed-off-by: glorv <glorvs@163.com>
  • Loading branch information
glorv authored Feb 7, 2023
1 parent 6a1ecaa commit 29dfcc2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/resourcecontrol/resource_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package resourcecontrol

import (
"reflect"
"unsafe"

"github.com/pingcap/kvproto/pkg/coprocessor"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
Expand All @@ -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}
Expand Down

0 comments on commit 29dfcc2

Please sign in to comment.