Skip to content

Randomize the random number generator's seed used in redis-benchmark#8174

Merged
madolson merged 1 commit intoredis:unstablefrom
x77a1:unstable
Dec 13, 2020
Merged

Randomize the random number generator's seed used in redis-benchmark#8174
madolson merged 1 commit intoredis:unstablefrom
x77a1:unstable

Conversation

@x77a1
Copy link
Contributor

@x77a1 x77a1 commented Dec 12, 2020

The pid of the benchmark process is used to randomize the random number generator's
seed. This ensures that when multiple benchmark processes are started at the same time
to generate load on a server, they use different seeds. This will ensure randomness in
the keys generated by those benchmark processes.

The pid of the benchmark process is used to randomize the random number generator's
seed. This ensures that when multiple benchmark processes are started at the same time
to generate load on a server, they use different seeds. This will ensure randomness in
the keys generated by different benchmark processes.
Copy link
Contributor

@madolson madolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing!

@madolson madolson merged commit ddd43b6 into redis:unstable Dec 13, 2020
@filipecosta90
Copy link
Contributor

filipecosta90 commented Dec 13, 2020

@madolson @x77a1 I believe this should be further discussed. IMHO this is adding further randomness, a bad type of randomness which is the uncontrollable one.
Even though this change does not impact deterministic benchmarks ( because we use the current time as the seed ) we should not change the current default and add a seed option -- taking the chance to do things in the proper manner.
Proposing to add:

  • --seed specify random seed used to generate random deterministic outputs. If none is specified that the current system time is used.

Then in your use case you can use different deterministic seeds in different benchmark processes.
This is what memtier_benchmark allows ( default 0, specify seed, and distinct client seeds ).

@x77a1
Copy link
Contributor Author

x77a1 commented Dec 14, 2020

@filipecosta90 A seed config is a good idea. However, I am not able to understand why using time as seed generates good randomness and using (time ^ getpid()) as seed generates a bad randomness. Could you please elaborate?

JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Mar 2, 2021
…edis#8174)

The pid of the benchmark process is used to randomize the random number generator's
seed. This ensures that when multiple benchmark processes are started at the same time
to generate load on a server, they use different seeds. This will ensure randomness in
the keys generated by different benchmark processes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants