Commit ddcf4f8d authored by marko's avatar marko

branches/zip: Remove some unnecessary memory references in the master thread.

srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined.  These variables
are never assigned to, and they are initialized to FALSE.  It could
be useful to set them when debugging InnoDB.

srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.

srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0.  The arrays are essentially constants that do not affect
the control flow.

enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
parent bd767175
......@@ -162,11 +162,19 @@ extern ibool srv_priority_boost;
extern ulint srv_mem_pool_size;
extern ulint srv_lock_table_size;
#ifdef UNIV_DEBUG
extern ibool srv_print_thread_releases;
extern ibool srv_print_lock_waits;
extern ibool srv_print_buf_io;
extern ibool srv_print_log_io;
extern ibool srv_print_latch_waits;
#else /* UNIV_DEBUG */
# define srv_print_thread_releases FALSE
# define srv_print_lock_waits FALSE
# define srv_print_buf_io FALSE
# define srv_print_log_io FALSE
# define srv_print_latch_waits FALSE
#endif /* UNIV_DEBUG */
extern ulint srv_activity_count;
extern ulint srv_fatal_semaphore_wait_threshold;
......@@ -286,6 +294,22 @@ of lower numbers are included. */
#define SRV_FORCE_NO_LOG_REDO 6 /* do not do the log roll-forward
in connection with recovery */
/** Types of threads existing in the system. */
enum srv_thread_type {
SRV_COM = 1, /**< threads serving communication and queries */
SRV_CONSOLE, /**< thread serving console */
SRV_WORKER, /**< threads serving parallelized queries and
queries released from lock wait */
#if 0
/* Utility threads */
SRV_BUFFER, /**< thread flushing dirty buffer blocks */
SRV_RECOVERY, /**< threads finishing a recovery */
SRV_INSERT, /**< thread flushing the insert buffer to disk */
#endif
SRV_MASTER /**< the master thread, (whose type number must
be biggest) */
};
/*************************************************************************
Boots Innobase server. */
......@@ -321,7 +345,7 @@ srv_get_n_threads(void);
/*************************************************************************
Returns the calling thread type. */
ulint
enum srv_thread_type
srv_get_thread_type(void);
/*=====================*/
/* out: SRV_COM, ... */
......@@ -341,11 +365,12 @@ NOTE! The server mutex has to be reserved by the caller! */
ulint
srv_release_threads(
/*================*/
/* out: number of threads released: this may be
< n if not enough threads were suspended at the
moment */
ulint type, /* in: thread type */
ulint n); /* in: number of threads to release */
/* out: number of threads
released: this may be < n if
not enough threads were
suspended at the moment */
enum srv_thread_type type, /* in: thread type */
ulint n); /* in: number of threads to release */
/*************************************************************************
The master thread controlling the server. */
......@@ -466,24 +491,6 @@ void
srv_export_innodb_status(void);
/*=====================*/
/* Types for the threads existing in the system. Threads of types 4 - 9
are called utility threads. Note that utility threads are mainly disk
bound, except that version threads 6 - 7 may also be CPU bound, if
cleaning versions from the buffer pool. */
#define SRV_COM 1 /* threads serving communication and queries */
#define SRV_CONSOLE 2 /* thread serving console */
#define SRV_WORKER 3 /* threads serving parallelized queries and
queries released from lock wait */
#define SRV_BUFFER 4 /* thread flushing dirty buffer blocks,
not currently in use */
#define SRV_RECOVERY 5 /* threads finishing a recovery,
not currently in use */
#define SRV_INSERT 6 /* thread flushing the insert buffer to disk,
not currently in use */
#define SRV_MASTER 7 /* the master thread, (whose type number must
be biggest) */
/* Thread slot in the thread table */
typedef struct srv_slot_struct srv_slot_t;
......
......@@ -344,11 +344,13 @@ ulong srv_thread_sleep_delay = 10000;
ulint srv_spin_wait_delay = 5;
ibool srv_priority_boost = TRUE;
#ifdef UNIV_DEBUG
ibool srv_print_thread_releases = FALSE;
ibool srv_print_lock_waits = FALSE;
ibool srv_print_buf_io = FALSE;
ibool srv_print_log_io = FALSE;
ibool srv_print_latch_waits = FALSE;
#endif /* UNIV_DEBUG */
ulint srv_n_rows_inserted = 0;
ulint srv_n_rows_updated = 0;
......@@ -579,9 +581,9 @@ Unix.*/
struct srv_slot_struct{
os_thread_id_t id; /* thread id */
os_thread_t handle; /* thread handle */
ulint type; /* thread type: user, utility etc. */
ibool in_use; /* TRUE if this slot is in use */
ibool suspended; /* TRUE if the thread is waiting
unsigned type:3; /* thread type: user, utility etc. */
unsigned in_use:1; /* TRUE if this slot is in use */
unsigned suspended:1; /* TRUE if the thread is waiting
for the event of this slot */
ib_time_t suspend_time; /* time when the thread was
suspended */
......@@ -607,6 +609,7 @@ byte srv_pad2[64]; /* padding to prevent other memory update
hotspots from residing on the same memory
cache line */
#if 0
/* The following three values measure the urgency of the jobs of
buffer, version, and insert threads. They may vary from 0 - 1000.
The server mutex protects all these variables. The low-water values
......@@ -618,6 +621,7 @@ ulint srv_meter_low_water[SRV_MASTER + 1];
ulint srv_meter_high_water[SRV_MASTER + 1];
ulint srv_meter_high_water2[SRV_MASTER + 1];
ulint srv_meter_foreground[SRV_MASTER + 1];
#endif
/* The following values give info about the activity going on in
the database. They are protected by the server mutex. The arrays
......@@ -687,8 +691,8 @@ static
ulint
srv_table_reserve_slot(
/*===================*/
/* out: reserved slot index */
ulint type) /* in: type of the thread: one of SRV_COM, ... */
/* out: reserved slot index */
enum srv_thread_type type) /* in: type of the thread */
{
srv_slot_t* slot;
ulint i;
......@@ -708,9 +712,9 @@ srv_table_reserve_slot(
slot->in_use = TRUE;
slot->suspended = FALSE;
slot->type = type;
slot->id = os_thread_get_curr_id();
slot->handle = os_thread_get_curr();
slot->type = type;
thr_local_create();
......@@ -728,10 +732,10 @@ srv_suspend_thread(void)
/*====================*/
/* out: event for the calling thread to wait */
{
srv_slot_t* slot;
os_event_t event;
ulint slot_no;
ulint type;
srv_slot_t* slot;
os_event_t event;
ulint slot_no;
enum srv_thread_type type;
ut_ad(mutex_own(&kernel_mutex));
......@@ -739,9 +743,8 @@ srv_suspend_thread(void)
if (srv_print_thread_releases) {
fprintf(stderr,
"Suspending thread %lu to slot %lu meter %lu\n",
(ulong) os_thread_get_curr_id(), (ulong) slot_no,
(ulong) srv_meter[SRV_RECOVERY]);
"Suspending thread %lu to slot %lu\n",
(ulong) os_thread_get_curr_id(), (ulong) slot_no);
}
slot = srv_table_get_nth_slot(slot_no);
......@@ -772,11 +775,12 @@ NOTE! The server mutex has to be reserved by the caller! */
ulint
srv_release_threads(
/*================*/
/* out: number of threads released: this may be
< n if not enough threads were suspended at the
moment */
ulint type, /* in: thread type */
ulint n) /* in: number of threads to release */
/* out: number of threads
released: this may be < n if
not enough threads were
suspended at the moment */
enum srv_thread_type type, /* in: thread type */
ulint n) /* in: number of threads to release */
{
srv_slot_t* slot;
ulint i;
......@@ -802,10 +806,9 @@ srv_release_threads(
if (srv_print_thread_releases) {
fprintf(stderr,
"Releasing thread %lu type %lu"
" from slot %lu meter %lu\n",
" from slot %lu\n",
(ulong) slot->id, (ulong) type,
(ulong) i,
(ulong) srv_meter[SRV_RECOVERY]);
(ulong) i);
}
count++;
......@@ -822,14 +825,14 @@ srv_release_threads(
/*************************************************************************
Returns the calling thread type. */
ulint
enum srv_thread_type
srv_get_thread_type(void)
/*=====================*/
/* out: SRV_COM, ... */
{
ulint slot_no;
srv_slot_t* slot;
ulint type;
ulint slot_no;
srv_slot_t* slot;
enum srv_thread_type type;
mutex_enter(&kernel_mutex);
......@@ -891,11 +894,13 @@ srv_init(void)
for (i = 0; i < SRV_MASTER + 1; i++) {
srv_n_threads_active[i] = 0;
srv_n_threads[i] = 0;
#if 0
srv_meter[i] = 30;
srv_meter_low_water[i] = 50;
srv_meter_high_water[i] = 100;
srv_meter_high_water2[i] = 200;
srv_meter_foreground[i] = 250;
#endif
}
UT_LIST_INIT(srv_sys->tasks);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment