Skip to content

Commit

Permalink
MB-55371 Fix under count of normalized WU/RU
Browse files Browse the repository at this point in the history
If WU/RU is less than the normalization factor, the units need to be
counted as 1.

Change-Id: I218959cd14eeed6d0c90880128a757c1d2f7446b
  • Loading branch information
deepkaran committed Feb 3, 2023
1 parent 0516306 commit 403ad22
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions secondary/indexer/plasma_slice.go
Expand Up @@ -3086,13 +3086,7 @@ func (mdb *plasmaSlice) updateUsageStats() {
}

//normalize the WU/RU and compute the current units usage

var writeUnitNormalizationFactor int64 = 1
if atomic.LoadInt32(&mdb.isInitialBuild) == 1 {
writeUnitNormalizationFactor = cInitBuildWUNormalizationFactor
}

currUnitsUsage := (newWUs / writeUnitNormalizationFactor) + (newRUs / cReadUnitNormalizationFactor)
currUnitsUsage := mdb.computeNormalizedWU(newWUs) + mdb.computeNormalizedRU(newRUs)

//update the last 20min max units usage, if applicable
max20minUnitsUsage := idxStats.max20minUnitsUsage.Value()
Expand All @@ -3109,6 +3103,40 @@ func (mdb *plasmaSlice) updateUsageStats() {
}
}

func (mdb *plasmaSlice) computeNormalizedWU(newWUs int64) int64 {

if newWUs == 0 {
return 0
}

var writeUnitNormalizationFactor int64 = 1
if atomic.LoadInt32(&mdb.isInitialBuild) == 1 {
writeUnitNormalizationFactor = cInitBuildWUNormalizationFactor
}

if newWUs < writeUnitNormalizationFactor {
return 1
}

normalizedWU := newWUs / writeUnitNormalizationFactor
return normalizedWU

}

func (mdb *plasmaSlice) computeNormalizedRU(newRUs int64) int64 {

if newRUs == 0 {
return 0
}

if newRUs < cReadUnitNormalizationFactor {
return 1
}

normalizedRU := newRUs / cReadUnitNormalizationFactor
return normalizedRU
}

func (mdb *plasmaSlice) updateUsageStatsOnCommit() {

if !mdb.EnableMetering() {
Expand Down

0 comments on commit 403ad22

Please sign in to comment.