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

Implement bpf_get_prandom_u32 using linear congruential generator #2761

Merged
merged 4 commits into from
Aug 17, 2023

Conversation

Alan-Jowett
Copy link
Member

@Alan-Jowett Alan-Jowett commented Aug 16, 2023

Description

The previous implementation of bpf_get_prandom_u32 relied on RtlGenRandomEx, which uses a single global state for its PRNG. Replacing this with a per-CPU PRNG implementation.

Testing

CI/CD

Documentation

No.

Installation

No.

Resolves: #2759

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
dthaler
dthaler previously approved these changes Aug 16, 2023
saxena-anurag
saxena-anurag previously approved these changes Aug 16, 2023
Copy link
Contributor

@saxena-anurag saxena-anurag left a comment

Choose a reason for hiding this comment

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

Were you able to get perf numbers for the new implementation as compared to Linux?

@dthaler dthaler enabled auto-merge August 16, 2023 16:50
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
@Alan-Jowett Alan-Jowett dismissed stale reviews from saxena-anurag and dthaler via 4b85f80 August 16, 2023 17:01
@Alan-Jowett
Copy link
Member Author

Were you able to get perf numbers for the new implementation as compared to Linux?

Yes. The cost of the RNG is around 5ns.

saxena-anurag
saxena-anurag previously approved these changes Aug 16, 2023
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
@Alan-Jowett Alan-Jowett changed the title Implment bpf_get_prandom_u32 using linear congruential generator Implement bpf_get_prandom_u32 using linear congruential generator Aug 17, 2023
@dthaler dthaler added this pull request to the merge queue Aug 17, 2023
Merged via the queue into microsoft:main with commit e57858f Aug 17, 2023
66 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.

bpf_get_prandom_u32 helper function is very slow
4 participants