go-kratos / aegis

Service Reliability Algorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bbr限流实现 maxInFlight 方法可能有误

DZGodly opened this issue · comments

return int64(math.Floor(float64(l.maxPASS()*l.minRT()*l.bucketPerSecond)/1000.0) + 0.5)

最后加的那个0.5是不是放错位置了。Floor函数返回的已经是一个整数值,在加 0.5 后,会被最外层的 int64() 截断吧

return int64(math.Floor(float64(l.maxPASS()*l.minRT()*l.bucketPerSecond)/1000.0) + 0.5)

最后加的那个0.5是不是放错位置了。Floor函数返回的已经是一个整数值,在加 0.5 后,会被最外层的 int64() 截断吧

+0.5 是为了向上取整

return int64(math.Floor(float64(l.maxPASS()*l.minRT()*l.bucketPerSecond)/1000.0) + 0.5)

最后加的那个0.5是不是放错位置了。Floor函数返回的已经是一个整数值,在加 0.5 后,会被最外层的 int64() 截断吧

+0.5 是为了向上取整

加错位置了吧,应该先加 0.5 再进行 Floor 操作吧

why not use math.Ceil() to get value greater than or equal to x ?

the comment for Ceil

// Ceil returns the least integer value greater than or equal to x.
//
// Special cases are:
//	Ceil(±0) = ±0
//	Ceil(±Inf) = ±Inf
//	Ceil(NaN) = NaN
func Ceil(x float64) float64

not same with +0.5

Hi, @DZGodly! I'm Dosu, and I'm here to help the aegis team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you raised a concern about a potential error in the implementation of the maxInFlight method in the bbr.go file of the go-kratos/aegis repository. Specifically, you questioned whether the placement of the 0.5 addition is incorrect, as the Floor function already returns an integer value that may be truncated by the int64() conversion. In the comments, haiyux and you discussed the placement of the 0.5 addition, while juwell suggested using math.Ceil() instead. lxkaka commented that +0.5 is not the same as using math.Ceil().

To help us keep track of the relevance of this issue, could you please let us know if it is still relevant to the latest version of the aegis repository? If it is, please comment on this issue to let us know. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days.

Thank you for your contribution to the go-kratos/aegis repository!