Skip to content

Conversation

@RaimoNiskanen
Copy link
Contributor

This PR polishes the rand:shuffle implementation a wee bit by using more bits from the raw PRNG, and using more of the already existing utility macros.

It also adds a few more tests and shell examples documentation for all functions.

Hidden in a side track is also tests to see if how much hard optimized shuffle functions could improve performance, but it ended up in not worth the complexity...

Also, use specified algorithms when measuring.
    * mwc59 and dedicated shuffle implementations:
      Revert "Try the speed of mwc59 in particular for shuffle"
      Revert "Try dedicated shuffle_mwc59"
      Revert "Try dedicated shuffle_exsss"
      Try dedicated shuffle_exsss
      Try dedicated shuffle_mwc59
      Try the speed of mwc59 in particular for shuffle

    Results:
    * mwc59 only makes a difference for shuffle, not for bytes
    * An inlined shuffle_mwc59 is about 20 % faster than exsss
    * An inlined shuffle_exsss is as fast as shuffle_mwc59

    Hence, it can give 20% to inline the PRNG functions in shuffle,
    so it is not worth the code duplication, and the speed of mwc59
    is buried in the shuffle algorithm so there is no point in
    having it in the plug-in framework.
@RaimoNiskanen RaimoNiskanen added this to the OTP-29.0 milestone Nov 24, 2025
@RaimoNiskanen RaimoNiskanen requested a review from dgud November 24, 2025 15:14
@RaimoNiskanen RaimoNiskanen self-assigned this Nov 24, 2025
@RaimoNiskanen RaimoNiskanen added team:PS Assigned to OTP team PS enhancement labels Nov 24, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

CT Test Results

    2 files     97 suites   1h 8m 1s ⏱️
2 223 tests 2 172 ✅ 51 💤 0 ❌
2 613 runs  2 557 ✅ 56 💤 0 ❌

Results for commit d8bb3cc.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

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

Labels

enhancement team:PS Assigned to OTP team PS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants