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

fix: change runtime.fastrand to runtime.cheaprand in go 1.22 #206

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

NX-Official
Copy link
Contributor

在 Go 1.22 中 runtime.fastrand 被重构,原先的版本被改为 runtime.cheaprand

但经过测试还是原先的版本更快,而且差距很大

image

所以我建议在 go 版本大于等于 1.22 时,使用 runtime.cheaprand 而不是 runtime.fastrand

ref: https://zhuanlan.zhihu.com/p/673906980

ps: 本人在复盘 Kitex 的 Alias Method 算法 ( cloudwego/kitex#1199 )时发现在 Go 1.22 版本下的性能倒退现象,追查到本项目的 fastrand ,而 fastrand 直接依赖于 runtime.fastrand

@zhangyunhao116 zhangyunhao116 merged commit 21fc7a1 into bytedance:develop Mar 15, 2024
2 of 3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants