Skip to content

Commit

Permalink
fix delta
Browse files Browse the repository at this point in the history
Signed-off-by: Connor1996 <[email protected]>
  • Loading branch information
Connor1996 committed Apr 19, 2023
1 parent 69e76bd commit 161cc6f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions client/resource_group/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ func (gc *groupCostController) onRequestWait(
}

gc.mu.Lock()
// calculate the penalty of the store
// Calculate the penalty of the store
penalty := &rmpb.Consumption{}
if storeCounter, exist := gc.mu.storeCounter[info.StoreID()]; exist {
*penalty = *gc.mu.globalCounter
Expand Down Expand Up @@ -1115,15 +1115,17 @@ func (gc *groupCostController) onResponse(
}

gc.mu.Lock()
// record the consumption of the request
// Record the consumption of the request
add(gc.mu.consumption, delta)
// record the consumption of the request by store
// Record the consumption of the request by store
count := &rmpb.Consumption{}
*count = *delta
// As the penalty is only counted when the request is completed, so here needs to calculate the write cost which is added in `BeforeKVRequest`
for _, calc := range gc.calculators {
calc.BeforeKVRequest(delta, req)
calc.BeforeKVRequest(count, req)
}
add(gc.mu.storeCounter[req.StoreID()], delta)
add(gc.mu.globalCounter, delta)
add(gc.mu.storeCounter[req.StoreID()], count)
add(gc.mu.globalCounter, count)
gc.mu.Unlock()

return delta, nil
Expand Down

0 comments on commit 161cc6f

Please sign in to comment.