[#915] blobovnicza: Use mean bucket size multiplier instead of min

For fullness estimation of `Blobovnicza` we use number of object stored
in each size bucket. In previous implementation we multiplied the number
by the difference in bucket boundaries. This expression rather
estimated the minimum volume (and for the smallest bucket, the maximum)
of objects in the bucket.

Multiply number of objects by mean bucket size.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-12-08 13:50:15 +03:00 committed by LeL
parent 2920c5203b
commit 90fd883e32

View file

@ -61,7 +61,7 @@ func (b *Blobovnicza) syncFullnessCounter(tx *bbolt.Tx) error {
return false, fmt.Errorf("bucket not found %s", stringifyBounds(lower, upper))
}
sz += uint64(buck.Stats().KeyN) * (upper - lower)
sz += uint64(buck.Stats().KeyN) * (upper + lower) / 2
return false, nil
}); err != nil {
@ -71,5 +71,4 @@ func (b *Blobovnicza) syncFullnessCounter(tx *bbolt.Tx) error {
b.filled.Store(sz)
return nil
}