go-zero
go-zero copied to clipboard
采用fastrand 替换 "math/rand" 来提升性能
Is your feature request related to a problem? Please describe. 根据他们测试的结果 https://github.com/bytedance/gopkg/tree/develop/lang/fastrand, fastrand 比math/rand 的使用要快不少,go-zero 中有不少场景使用了math/rand
Describe the solution you'd like 如果适合 go-zero 这边的话,我来提交一个pr
Describe alternatives you've considered https://github.com/valyala/fastrand 这个也许也是合适的
Additional context math/rand全局共享了同一个 globalRand 对象,fastrand 使用 go:linkname 直接调用了 runtime.fastrand
感谢哈,不过这个不需要,原因有两个:
- 这个对性能的影响极低
- 尽可能减少包依赖
非常感谢哈