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

refactor: replace deprecated 'golang.org/x/exp/rand' to 'math/rand/v2' #6274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yudrywet
Copy link

Summary

golang.org/x/exp/rand will be deprecated. Use math/rand/v2 in std.

For more info can see https://go.dev/issue/61716.

Test Plan

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.68%. Comparing base (cbfa226) to head (2363b3d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6274      +/-   ##
==========================================
- Coverage   51.69%   51.68%   -0.01%     
==========================================
  Files         646      646              
  Lines       86860    86860              
==========================================
- Hits        44901    44893       -8     
- Misses      39095    39103       +8     
  Partials     2864     2864              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -488,7 +488,7 @@ func TestAppRateLimiter_TxgroupToKeys(t *testing.T) {
}

func BenchmarkAppRateLimiter_TxgroupToKeys(b *testing.B) {
rnd := rand.New(rand.NewSource(123))
rnd := rand.New(rand.NewPCG(0, 123))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use this: rnd := rand.NewChaCha8(seed) you won't have to change the Read() calls, I think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it does seem so. I want to write a detailed demo to try it out later.

Copy link
Contributor

@algorandskiy algorandskiy Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used pseudo-random numbers in assumption they are a bit faster than reading crypto/rand source.
chacha should be fine - it appears to maintain all it state in memory, no syscalls/etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants