Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DZGodly opened this issue Mar 2, 2022 · 5 comments
Closed

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

DZGodly opened this issue Mar 2, 2022 · 5 comments

Comments

@DZGodly
Copy link

DZGodly commented Mar 2, 2022

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

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

@daemon365
Copy link
Member

daemon365 commented Mar 2, 2022

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

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

+0.5 是为了向上取整

@DZGodly
Copy link
Author

DZGodly commented Mar 13, 2022

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 操作吧

@juwell
Copy link

juwell commented Mar 28, 2022

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

@lxkaka
Copy link

lxkaka commented Nov 15, 2022

not same with +0.5

Copy link

dosubot bot commented Nov 2, 2023

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!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 2, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants