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

Improve pseudoRandom performance with bitwise operation #51

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

Conversation

ggiver
Copy link

@ggiver ggiver commented Oct 30, 2024

Currently, pseudoRandom calculation uses the mod operator, which turns into fmod in the end. On non-x86 platforms, there's no hardware accelerated fmod operation, which leads to a high CPU loading and bottleneck under the software fmod calculations.
Since the divisor RANDOM_RANGE is a power of 2, it can be replaced by bitwise operation, which can improve the performance a lot on non-x86 platforms and make the workload and performance more aligned among all platforms. It can also slightly improve the performance on x86 platforms.

Currently, pseudoRandom calculation uses the mod operator, which turns
into fmod in the end. On non-x86 platforms, there's no hardware
accelerated fmod operation, which leads to a high CPU loading and
bottleneck under the software fmod calculations.
Since the divisor RANDOM_RANGE is a power of 2, it can be replaced by
bitwise operation, which can improve the performance a lot on non-x86
platforms and make the workload and performance more aligned among
all platforms. It can also slightly improve the performance on x86
platforms.
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.

1 participant