sentinel-golang
sentinel-golang copied to clipboard
what does the reset() of MetricBucket do? seems no references
https://github.com/alibaba/sentinel-golang/blob/c362aaeafd1e500c9812d4961bcea81b25008b45/core/stat/base/metric_bucket.go#L68
another question: the minrt updating function is not thread safe.
func (mb *MetricBucket) AddRt(rt int64) {
mb.addCount(base.MetricEventRt, rt)
if rt < atomic.LoadInt64(&mb.minRt) { // here is not thread safe.
// Might not be accurate here.
atomic.StoreInt64(&mb.minRt, rt)
}
}
what does the reset() of MetricBucket do? seems no references
This was designed for refreshing the deprecated bucket (i.e. ResetBucketTo
of BucketGenerator) but not used (maybe forgotten). Would you like to submit a PR to improve it?
i can do this in my spare time
@sczyh30 I think you mean that the existing reset() function is not being used and a new MetricBucket is recreated in the ResetBucketTo() function. Therefore, you want to optimize your code to call reset() to avoid this unnecessary operation. Is that so?
@sczyh30 I think you mean that the existing reset() function is not being used and a new MetricBucket is recreated in the ResetBucketTo() function. Therefore, you want to optimize your code to call reset() to avoid this unnecessary operation. Is that so?
Yeah, that's it.