Skip to content

Conversation

mirounga
Copy link
Contributor

@mirounga mirounga commented Jan 27, 2025

I have traced the optimization to the following paper:

Carta, David F. "Two fast implementations of the “minimal standard” random number generator." Communications of the ACM 33, no. 1 (1990): 87-88.

BEFORE:

Benchmark Time CPU Iterations

BM_lcg 4.44 ns 4.45 ns 154482759

AFTER:

Benchmark Time CPU Iterations

BM_lcg 2.09 ns 2.09 ns 344615385

Double the speed

@mirounga mirounga requested a review from a team as a code owner January 27, 2025 21:03
@StephanTLavavej StephanTLavavej added the performance Must go faster label Jan 27, 2025
@StephanTLavavej StephanTLavavej self-assigned this Jan 28, 2025
@mirounga mirounga requested a review from AlexGuteniev March 3, 2025 19:59
@StephanTLavavej StephanTLavavej removed their assignment Mar 3, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Mar 3, 2025
@StephanTLavavej StephanTLavavej changed the title Optimized divisionless implementation of minstd <random>: Optimized divisionless implementation of minstd_rand, minstd_rand0 Mar 3, 2025
@StephanTLavavej
Copy link
Member

Thanks! I pushed a conflict-free merge with main (as we had updated Google Benchmark), followed by commits to simplify the code and expand the comment.

We merge PRs simultaneously to our GitHub and MSVC-internal repos in a semi-manual process, batched up to save time. Your PR will be part of the next batch; I'll post comments here as I prepare it for merging, likely next week.

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Mar 12, 2025
@StephanTLavavej StephanTLavavej self-assigned this Mar 12, 2025
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 1cbf316 into microsoft:main Mar 13, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Mar 13, 2025
@StephanTLavavej
Copy link
Member

Thanks again for this performance improvement! This should ship in VS 2022 17.14 Preview 3. 😻 🚀 🎉

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

Labels

performance Must go faster

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants