Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-72

Create a RandomSource.create benchmark

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Done
    • 1.3
    • 1.3
    • simple

    Description

      The recommended method to construct a UniformRandomProvider is to use, e.g.:

      import org.apache.commons.rng.UniformRandomProvider;
      import org.apache.commons.rng.simple.RandomSource;
      
      UniformRandomProvider rng = RandomSource.create(RandomSource.MWC_256);
      

      The factory method knows the type of seed required for the constructor and generates one as appropriate.

      This factory method could be made more efficient, in particular:

      • Reducing synchronisation around the single source of random seed data
      • Adding knowledge of the required seed size for arrays
      • Changing internal data structures, e.g. Map<Class<?>, SeedConverter<?,?>> can be changed to Map<SeedType, SeedConverter<?,?>> using an EnumMap if a new enum SeedType was created for all the supported seeds (currently 4 types).
      • Add a new interface to replace SeedConverter<?,?>.convert() with a .convert(int outputArraySize) method to allow conversions to generate appropriately sized arrays. The parameter can be ignored for non-array conversions but could optimise array conversions.

      This ticket is to add a JMH benchmark to compare the speed of construction of all the providers using:

      • Their native constructor
      • RandomSource using the native seed of the correct size (calls a constructor using reflection)
      • RandomSource using a non native seed (requires seed conversion)
      • RandomSource using no seed (requires seed generation)

      The report will be posted here. It could be added to the user guide for reference.

      This work is motivated by the new XorShiRo generators in version 1.3 that have a native array seed size of 2, 4, or 8. The current RandomSource create method will generate a fixed seed of length 128 for seeding.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            aherbert Alex Herbert
            aherbert Alex Herbert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                Slack

                  Issue deployment