Skip to content

Commit 3fffaed

Browse files
Yasufumi Kinoshitadahlerlend
Yasufumi Kinoshita
authored andcommitted
Bug#37212019: behavior related to innodb_spin_wait_delay changed in 8.0.30
To keep innodb_spin_wait_delay behavior exactly same, ut::random_from_interval_fast() is better to be aligned to the previous function ut_rnd_interval() behavior, even seems a little strange. ut_rnd_interval(low, high) returned only [low, high - 1], and the current all of users' innodb_spin_wait_delay settings depend on the behavior. ut::random_from_interval_fast(low, high) returns [low, high] and the spin_wait_delay behavior can be longer than the previous 8.0.30. ut::random_from_interval_fast() is used almost only for innodb_spin_wait_delay currently. To adjust it is the minimum change and the smallest side-effect. Change-Id: I98f1f94514fa3a4bfa5484a75b4f395dc944f6cf
1 parent e369cc5 commit 3fffaed

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

storage/innobase/include/ut0rnd.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ static inline uint64_t random_from_interval(uint64_t low, uint64_t high) {
183183
}
184184

185185
static inline uint64_t random_from_interval_fast(uint64_t low, uint64_t high) {
186-
return random_from_interval_gen<random_64_fast>(low, high);
186+
/* FIXME: To keep backward compatibility with the previous ut_rnd_interval(),
187+
high value is not to be returned to keep same behavior for performance tuning
188+
parameter.
189+
(Bug#37212019: behavior related to innodb_spin_wait_delay changed in 8.0.30)
190+
This function is not required accurate randomness, no real problems. */
191+
192+
if (low == high) {
193+
return (low);
194+
}
195+
196+
return random_from_interval_gen<random_64_fast>(low, high - 1);
187197
}
188198

189199
static inline uint64_t hash_uint64(uint64_t value) {

unittest/gunit/innodb/ut0rnd-t.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static void test_interval_fast_distribution(uint64_t n) {
369369
const uint64_t max_score = 17000;
370370

371371
for (uint64_t i = 0; i < max_count; i++) {
372-
const auto value = ut::random_from_interval_fast(0, n - 1);
372+
const auto value = ut::random_from_interval_fast(0, n);
373373
for (auto *target : target_score) {
374374
if (value == target[0]) {
375375
target[1]++;

0 commit comments

Comments
 (0)