commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (RNG-57) CachedUniformRandomProvider for nextBoolean() and nextInt()
Date Tue, 02 Oct 2018 14:01:00 GMT

    [ https://issues.apache.org/jira/browse/RNG-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16635531#comment-16635531
] 

Gilles commented on RNG-57:
---------------------------

bq. I was referring to updating the User Guide by rerunning the benchmark.

So did I.
Only the "Generating int values" table must be changed.  Correct?
Perhaps add a table for "nextBoolean()"?

bq. I've not tested if the system then performs worse on the DieHarder or BigCrush tests.

These tools test randomness in chunks of 32 bits. IIRC, the Java code that bridges to them
only calls the {{nextInt()}} method.
So the only impact would a bug in the implementation of the {{nextInt()}} cache on a {{LongProvider}};
but there should be a unit test for that (rather than rely on long-running external software).

bq. Rerun the DieHarder and BigCrush tests for LongProvider

That should not be necessary (cf. above).
Unless you suspect that some of the good results were because half of the generated bits were
thrown away... (?)

bq. How should this be divided up into issues and PRs?

Your suggested division looks fine.
I could have a look at the {{RestorableUniformRandomProvider}} part (unless you absolutely
want to do it).


> CachedUniformRandomProvider for nextBoolean() and nextInt()
> -----------------------------------------------------------
>
>                 Key: RNG-57
>                 URL: https://issues.apache.org/jira/browse/RNG-57
>             Project: Commons RNG
>          Issue Type: Improvement
>          Components: sampling
>    Affects Versions: 1.2
>            Reporter: Alex D Herbert
>            Priority: Minor
>              Labels: performance
>
> Implement a wrapper around a {{UniformRandomProvider}} that can cache the underlying
source of random bytes for use in the methods {{nextBoolean()}} and {{nextInt()}} (in the
case of {{LongProvider}}). E.g.
> {code:java}
> LongProvider provider = RandomSource.create(RandomSource.SPLIT_MIX_64);
> CachedLongProvider rng = new CachedLongProvider(provider);
> // Uses cached nextLong() 64 times
> rng.nextBoolean();
> // Uses cached nextLong() twice
> rng.nextInt();
> IntProvider provider = RandomSource.create(RandomSource.KISS);
> CachedIntProvider rng2 = new CachedIntProvider(provider);
> // Uses cached nextInt() 32 times
> rng2.nextBoolean();
> // This could be wrapped by a factory method:
> UniformRandomProvider rng = CachedUniformRandomProviderFactory.wrap(
>         // Any supported source: IntProvider or LongProvider
>         RandomSource.create(RandomSource...));
> {code}
> The implementation should be speed tested to determine the benefit for {{nextBoolean()}}
and if {{nextInt()}} can be improved for {{LongProviders}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message