Skip to content

Commit

Permalink
Revert "Bug #22733635 CACHE LINE CONTENTION ON UT_RND_ULINT_COUNTER"
Browse files Browse the repository at this point in the history
This reverts commit 1994f43daafbb1b6b2cd44894ba6a7944bc22260.

(cherry picked from commit be7b121f2cb49de03fa993599d203f616072853b)
  • Loading branch information
Aakanksha Verma authored and Hery Ramilison committed Jul 11, 2016
1 parent daa892a commit 1f906de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
8 changes: 1 addition & 7 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ enum_tx_isolation thd_get_trx_isolation(const THD* thd);

/* for ha_innopart, Native InnoDB Partitioning. */
#include "ha_innopart.h"
extern thread_local_key_t ut_rnd_ulint_counter_key;

/** to protect innobase_open_files */
static mysql_mutex_t innobase_share_mutex;
/** to force correct commit order in binlog */
Expand Down Expand Up @@ -3481,11 +3481,6 @@ innobase_init(
ulong num_pll_degree;

DBUG_ENTER("innobase_init");

/* Create key for setting ut_rnd_ulint_counter for spin lock
delay as thread local. */
my_create_thread_local_key(&ut_rnd_ulint_counter_key,NULL);

handlerton* innobase_hton= (handlerton*) p;
innodb_hton_ptr = innobase_hton;

Expand Down Expand Up @@ -4108,7 +4103,6 @@ innobase_end(
mysql_cond_destroy(&commit_cond);
}

my_delete_thread_local_key(ut_rnd_ulint_counter_key);
DBUG_RETURN(err);
}

Expand Down
28 changes: 5 additions & 23 deletions storage/innobase/include/ut0rnd.ic
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Created 5/30/1994 Heikki Tuuri
#define UT_XOR_RND1 187678878
#define UT_XOR_RND2 143537923

#include <my_thread_local.h>
/** Seed value of ut_rnd_gen_ulint() */
extern ulint ut_rnd_ulint_counter;

extern thread_local_key_t ut_rnd_ulint_counter_key;
/********************************************************//**
This is used to set the random number seed. */
UNIV_INLINE
Expand All @@ -49,13 +49,11 @@ ut_rnd_set_seed(
/*============*/
ulint seed) /*!< in: seed */
{
/* Setting the seed value as thread local */
my_set_thread_local(ut_rnd_ulint_counter_key,(void *)seed);
ut_rnd_ulint_counter = seed;
}

/********************************************************//**
The following function generates a series of 'random' ulint integers.
This function is now based on thread local variables.
@return the next 'random' number */
UNIV_INLINE
ulint
Expand Down Expand Up @@ -83,39 +81,23 @@ The following function generates 'random' ulint integers which
enumerate the value space of ulint integers in a pseudo random
fashion. Note that the same integer is repeated always after
2 to power 32 calls to the generator (if ulint is 32-bit).
This function is now based on thread local variables.
@return the 'random' number */
UNIV_INLINE
ulint
ut_rnd_gen_ulint(void)
/*==================*/
{
ulint rnd;
void* rnd_count_value;

rnd_count_value = my_get_thread_local(ut_rnd_ulint_counter_key);
ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2;

if(!rnd_count_value) {
/* Reset the value if we recieve NULL rnd value i.e.
coming from new thread */
rnd = 65654363;
} else {
/* Set otherwise rnd to non null recieved from the
existing thread */
rnd = (ulint) rnd_count_value;
}

rnd = UT_RND1 * rnd + UT_RND2;
/* Setting the rnd value as thread local */
my_set_thread_local(ut_rnd_ulint_counter_key,(void *)rnd);
rnd = ut_rnd_gen_next_ulint(rnd);
rnd = ut_rnd_gen_next_ulint(ut_rnd_ulint_counter);

return(rnd);
}

/********************************************************//**
Generates a random integer from a given interval.
This function is now based on thread local variables.
@return the 'random' number */
UNIV_INLINE
ulint
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/ut/ut0rnd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Created 5/11/1994 Heikki Tuuri
********************************************************************/

#include "ut0rnd.h"
#include <my_thread_local.h>

#ifdef UNIV_NONINL
#include "ut0rnd.ic"
Expand All @@ -37,8 +36,9 @@ Created 5/11/1994 Heikki Tuuri
#define UT_RANDOM_3 1.0132677
/*@}*/

/** Key for thread local variable ut_rnd_ulint_counter */
thread_local_key_t ut_rnd_ulint_counter_key;
/** Seed value of ut_rnd_gen_ulint(). */
ulint ut_rnd_ulint_counter = 65654363;

/***********************************************************//**
Looks for a prime number slightly greater than the given argument.
The prime is chosen so that it is not near any power of 2.
Expand Down

0 comments on commit 1f906de

Please sign in to comment.