diff options
author | Yves Orton <demerphq@gmail.com> | 2022-08-05 13:18:02 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-08-12 22:29:05 +0200 |
commit | bf2a3dae9f4f828fd1f2f8aaf4769f96520c9552 (patch) | |
tree | b58ad50f0d8d828bb5a890686e0ce7e82ae529ae /pod/perlrun.pod | |
parent | 08da5deb5d0c842dab3fe5f4f5a450972a0eb67c (diff) | |
download | perl-bf2a3dae9f4f828fd1f2f8aaf4769f96520c9552.tar.gz |
Add a new env var PERL_RAND_SEED
This env var can be used to trigger a repeatable run of a script which
calls C<srand()> with no arguments, either explicitly or implicitly
via use of C<rand()> prior to calling srand(). This is implemented in
such a way that calling C<srand()> with no arguments in forks or
subthreads (again explicitly or implicitly) will receive their own seed
but the seeds they receive will be repeatable.
This is intended for debugging and perl development performance testing,
and for running the test suite consistently. It is documented that the
exact seeds used to initialize the random state are unspecified, and
that they may change between releases or even builds. The only guarantee
provided is that the same perl executable will produce the same results
twice all other things being equal. In practice and in core testing we
do expect consistency, but adding the tightest set of restrictions on
our commitments seemed sensible.
The env var is ignored when perl is run setuid or setgid similarly to
the C<PERL_INTERNAL_RAND_SEED> env var.
Diffstat (limited to 'pod/perlrun.pod')
-rw-r--r-- | pod/perlrun.pod | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pod/perlrun.pod b/pod/perlrun.pod index 0b5a6d3875..6ed5703811 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -1405,6 +1405,32 @@ with tainting enabled. Perl may be built to ignore this variable. +=item PERL_RAND_SEED +X<PERL_RAND_SEED> + +When set to an integer value this value will be used to seed the perl +internal random number generator used for C<rand()> when it is used +without an explicit C<srand()> call or for when an explicit no-argument +C<srand()> call is made. + +Normally calling C<rand()> prior to calling C<srand()> or calling +C<srand()> explicitly with no arguments should result in the random +number generator using "best efforts" to seed the generator state with a +relatively high quality random seed. When this environment variable is +set then the seeds used will be deterministically computed from the +value provided in the env var in such a way that the application process +and any forks or threads should continue to have their own unique seed but +that the program may be run twice with identical results as far as +C<rand()> goes (assuming all else is equal). + +PERL_RAND_SEED is intended for performance measurements and debugging +and is explicitly NOT intended for stable testing. The only guarantee is +that a specific perl executable will produce the same results twice in a +row, there is no guarantee that the results will be the same between +perl releases or on different architectures. + +Ignored if perl is run setuid or setgid. + =back Perl also has environment variables that control how Perl handles data |