Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Latest commit

 

History

History
111 lines (75 loc) · 4.52 KB

CHANGES.md

File metadata and controls

111 lines (75 loc) · 4.52 KB

List of changes on sfmt-erlang

Build and test commands since 0.14.0

  • Building: rebar3 compile
  • C NIF Documentation: doxygen (requires Doxygen 1.9.1 or later)
  • Erlang Documentation: rebar3 edoc
  • Testing: rebar3 ct
  • Execution speed benchmark: execute rebar3 shell and run sfmt_tests:test_speed() and sfmt_pure_tests:test_speed()
  • Cleaning up: rebar3 clean

Use rebar3 to build since 0.14.0

  • Since 14.0, erlang.mk and mix.exs are removed. Use rebar3 to build.

Use 0.13.2 and later for OTP 23

  • erlang.mk is updated to stop using -lerl_interface. This is required for successfully build in OTP 23.

Security notice added

See Security notice regarding the PHP mt_seed() vulnerability in the README.md.

Pigeonhole principle enforced

  • From 0.13.0
  • See Issue #23 at #23
  • On uniform/1 and uniform_s/2
  • This will enforce the probability values for all possible numbers showing up in the random number sequence of X ranged in 1 <= X <= N are equal with each other

Possible errors on mixing up floats and integers existed on 0.12.8 and older versions

  • 0.12.8 and older versions had a bug of possibly mixing up floats and integers when sfmt:uniform/0 and sfmt:uniform/1 are called in sequence
  • From 0.13.0, float values are no longer precomputed and generated from 32-bit integers of SFMT output each time. uniform/0 and uniform_s/1 are affected
  • Float NIFs are no longer available from 0.13.0

output interval changed to (0.0, 1.0)

  • uniform/0 and uniform_s/1 output X range: 0.0 < X < 1.0 (from 0.12.0)
  • This change fixes the scaling bug on uniform/1, uniform_s/2
  • Thx @timCF on GitHub for pointing this out

seeding semantics now consistent between sfmt and sfmt_pure modules

  • sfmt_pure:seed0/0 is fixed to be consistent with sfmt_seed0/0 (from 0.12.0)

hex.pm support added

  • Based on the contribution from Michael Chmielewski (from 0.10.1)
  • Package name on hex.pm: sfmt
  • hexdocs.pm supported (from 0.12.8)

NIF code simplified

  • All atoms defined inside the NIF code are removed (from 0.10.0)
  • if enif_alloc() fails, enif_make_badarg() is called instead of returning error_sfmt_nomem (from 0.10.0)

Test framework changed from EUnit to Common Test

  • Common Test source included under test/ (from 0.10.0)

Rebar dependency removed

  • Rebar dependency removed, now uses erlang.mk (from 0.10.0)
  • Uses erlang.mk NIF support (from 0.10.0)

Pure Erlang SFMT module

  • Pure Erlang SFMT module now added as working code by request (from 0.8.0_RELEASE)

Seeding algorithm changed for seed(integer()) functions

  • The old seed/1 function called init_gen_rand/1 (up to 0.8.0_RELEASE)
  • The internal state generated by init_gen_rand/1 is predictable, especially when the value of the 1st element of the state list is very close to the given seed value. (Michael Gebetsroither discovered this behavior)
  • The new seed/1 function calls init_by_list32/1 (from 0.8.1_RELEASE) and the seed is given as [integer()], to reduce predictability of the 1st element of the state list.

C NIFs

  • MSC/BORLANDC compilation flags removed (from 0.9.1_BETA)
  • C NIFs based on SFMT 1.3.3 added (from 0.3.0_RELEASE)
  • The version number of this NIF is 101 (see NIF_LOAD_INFO macro value)

Notable bugfixes

  • asn1 application now starts before starting up public_key application on support/getrebar (from 0.9.1_BETA)
  • gen_rand_all/1 is now properly applied in sfmt_pure module when gen_rand32/1 was first invoked (from 0.8.2_RELEASE)
  • Catched up with the latest rebar configuration file (from 0.7.0_RELEASE)
  • Dynamically building ebin/sfmt.app (from 0.7.0_RELEASE)
  • PDIC_SEED now named differently for each period (bugfix, from 0.5.2_RELEASE)

Removed code

  • Wichmann-Hill 2006 RNG code is removed
  • netpbm test code is removed

Notes on refactoring

  • Speedup by NIF: ~40 times faster than the pure Erlang code (when fully inline-optimized (see rebar.config))
  • For the pure-Erlang code: writing ++ (append) operators by ring buffer loops (as a pair of lists consuming the head elements, and the corresponding accumulators) made the code ~50% faster; the pure Erlang code available under reference_texts/
  • gen_rand32/1, gen_rand32_max/2, and gen_rand_float/1 use Erlang lists (Dan Gudmudsson showed the list version is faster)
  • SSE2 code and options in sfmt-extstate were removed due to causing crash of Erlang BEAM (and even if the SSE2 code was enabled the performance increase would be minimal)