saghul / sjs

Skookum JS: a JavaScript runtime
http://sjs.saghul.net
MIT License
97 stars 13 forks source link

Consider switching to xoroshiro128+ for RNG #37

Open fatcerberus opened 8 years ago

fatcerberus commented 8 years ago

I recently switched from Mersenne Twister (MT19937) to xoroshiro128+ for random number generation in minisphere. It's about 4 times as fast as MT, generates 64-bit unsigned integers, is higher quality (i.e. passes more randomness tests), and is in the public domain. It's the successor to the xorshift128+ algorithm currently used by SpiderMonkey and V8:

The implementation I wrote for minisphere allows creating multiple generator instances as well as saving and restoring the state of the generator. Since the state is only 128-bit it can be represented as a single 32-character hex string that you can write to a file and read back later. MT19937 has nearly 2.5KB of state making it a bit unwieldy.

Here's my implementation if you want to look at it:

saghul commented 8 years ago

Thanks for the heads up!