List:Internals« Previous MessageNext Message »
From:Vadim Tkachenko Date:June 10 2005 3:41pm
Subject:bk commit into 5.0-hp tree (vtkachenko:1.1944)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0-hp repository of vtkachenko. When vtkachenko does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1944 05/06/10 15:41:24 vtkachenko@stripped +7 -0
  Many files:
    rw_lock stats

  sql/ha_innodb.cc
    1.211 05/06/10 15:40:49 vtkachenko@stripped +82 -0
    rw_lock stats

  mysys/thr_mutex.c
    1.28 05/06/10 15:40:49 vtkachenko@stripped +2 -2
    rw_lock stats

  innobase/sync/sync0rw.c
    1.20 05/06/10 15:40:49 vtkachenko@stripped +53 -5
    rw_lock stats

  innobase/include/sync0rw.ic
    1.10 05/06/10 15:40:49 vtkachenko@stripped +32 -5
    rw_lock stats

  innobase/include/sync0rw.h
    1.12 05/06/10 15:40:49 vtkachenko@stripped +23 -15
    rw_lock stats

  innobase/include/mtr0mtr.ic
    1.4 05/06/10 15:40:48 vtkachenko@stripped +2 -2
    rw_lock stats

  innobase/buf/buf0buf.c
    1.46 05/06/10 15:40:48 vtkachenko@stripped +2 -2
    rw_lock stats

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	vtkachenko
# Host:	quadxeon.mysql.com
# Root:	/users/vtkachenko/bk/HP/mysql-5.0-hp2

--- 1.27/mysys/thr_mutex.c	2005-05-12 23:08:18 +02:00
+++ 1.28/mysys/thr_mutex.c	2005-06-10 15:40:49 +02:00
@@ -471,7 +471,7 @@
   uint maxdelay= 64;
 
   timed_mutex_root[mp->indx_in_stat_array].lock_count++;
-
+/* Problems with loop on melody, need to discover
   for (i= 0; i < 20; i++)
   {
     res= pthread_mutex_trylock(&mp->mutex);
@@ -484,7 +484,6 @@
       return res;
 
 
-    /* do delay */
     	j= 0;
 
       delay= maxdelay;
@@ -498,6 +497,7 @@
   }
 
   timed_mutex_root[mp->indx_in_stat_array].spin_loops_count += i;
+*/  
   if (timed_mutexes == 1)
   {
     my_utime(&sec, &ms);

--- 1.45/innobase/buf/buf0buf.c	2004-12-14 20:26:25 +01:00
+++ 1.46/innobase/buf/buf0buf.c	2005-06-10 15:40:48 +02:00
@@ -1233,11 +1233,11 @@
 		fix_type = MTR_MEMO_BUF_FIX;
 	} else if (rw_latch == RW_S_LATCH) {
 
-		rw_lock_s_lock_func(&(block->lock), 0, file, line);
+		rw_lock_s_lock(&(block->lock));
 
 		fix_type = MTR_MEMO_PAGE_S_FIX;
 	} else {
-		rw_lock_x_lock_func(&(block->lock), 0, file, line);
+		rw_lock_x_lock(&(block->lock));
 
 		fix_type = MTR_MEMO_PAGE_X_FIX;
 	}

--- 1.3/innobase/include/mtr0mtr.ic	2004-05-14 15:06:15 +02:00
+++ 1.4/innobase/include/mtr0mtr.ic	2005-06-10 15:40:48 +02:00
@@ -224,7 +224,7 @@
 	ut_ad(mtr);
 	ut_ad(lock);
 
-	rw_lock_s_lock_func(lock, 0, file, line);
+	rw_lock_s_lock_func(lock, 0, file, line, "mtr_lock");
 
 	mtr_memo_push(mtr, lock, MTR_MEMO_S_LOCK);
 }
@@ -243,7 +243,7 @@
 	ut_ad(mtr);
 	ut_ad(lock);
 
-	rw_lock_x_lock_func(lock, 0, file, line);
+	rw_lock_x_lock_func(lock, 0, file, line, "mtr_lock");
 
 	mtr_memo_push(mtr, lock, MTR_MEMO_X_LOCK);
 }

--- 1.11/innobase/include/sync0rw.h	2005-01-03 21:23:58 +01:00
+++ 1.12/innobase/include/sync0rw.h	2005-06-10 15:40:49 +02:00
@@ -99,13 +99,13 @@
 corresponding function. */
 
 #define rw_lock_s_lock(M)    rw_lock_s_lock_func(\
-					  (M), 0, __FILE__, __LINE__)
+					  (M), 0, __FILE__, __LINE__, #M)
 /******************************************************************
 NOTE! The following macros should be used in rw s-locking, not the
 corresponding function. */
 
 #define rw_lock_s_lock_gen(M, P)    rw_lock_s_lock_func(\
-					  (M), (P), __FILE__, __LINE__)
+					  (M), (P), __FILE__, __LINE__, #M)
 /******************************************************************
 NOTE! The following macros should be used in rw s-locking, not the
 corresponding function. */
@@ -127,7 +127,7 @@
 	ulint		pass,	/* in: pass value; != 0, if the lock will
 				be passed to another thread to unlock */
 	const char*	file_name,/* in: file name where lock requested */
-	ulint		line);	/* in: line where requested */
+	ulint		line, char* lock_name);	/* in: line where requested */
 /**********************************************************************
 NOTE! Use the corresponding macro, not directly this function, except if
 you supply the file name and line number. Lock an rw-lock in shared mode
@@ -163,35 +163,36 @@
 	,ulint		pass	/* in: pass value; != 0, if the lock may have
 				been passed to another thread to unlock */
 #endif
+  ,char* lock_name
 	);
 /***********************************************************************
 Releases a shared mode lock. */
 
 #ifdef UNIV_SYNC_DEBUG
-#define rw_lock_s_unlock(L)    rw_lock_s_unlock_func(L, 0)
+#define rw_lock_s_unlock(L)    rw_lock_s_unlock_func(L, 0, #L)
 #else
-#define rw_lock_s_unlock(L)    rw_lock_s_unlock_func(L)
+#define rw_lock_s_unlock(L)    rw_lock_s_unlock_func(L, #L)
 #endif
 /***********************************************************************
 Releases a shared mode lock. */
 
 #ifdef UNIV_SYNC_DEBUG
-#define rw_lock_s_unlock_gen(L, P)    rw_lock_s_unlock_func(L, P)
+#define rw_lock_s_unlock_gen(L, P)    rw_lock_s_unlock_func(L, P, #L)
 #else
-#define rw_lock_s_unlock_gen(L, P)    rw_lock_s_unlock_func(L)
+#define rw_lock_s_unlock_gen(L, P)    rw_lock_s_unlock_func(L, #L)
 #endif
 /******************************************************************
 NOTE! The following macro should be used in rw x-locking, not the
 corresponding function. */
 
 #define rw_lock_x_lock(M)    rw_lock_x_lock_func(\
-					  (M), 0, __FILE__, __LINE__)
+					  (M), 0, __FILE__, __LINE__, #M)
 /******************************************************************
 NOTE! The following macro should be used in rw x-locking, not the
 corresponding function. */
 
 #define rw_lock_x_lock_gen(M, P)    rw_lock_x_lock_func(\
-					  (M), (P), __FILE__, __LINE__)
+					  (M), (P), __FILE__, __LINE__, #M)
 /******************************************************************
 NOTE! The following macros should be used in rw x-locking, not the
 corresponding function. */
@@ -215,7 +216,7 @@
 	ulint		pass,	/* in: pass value; != 0, if the lock will
 				be passed to another thread to unlock */
 	const char*	file_name,/* in: file name where lock requested */
-	ulint		line);	/* in: line where requested */
+	ulint		line, char* lock_name);	/* in: line where requested */
 /**********************************************************************
 Releases an exclusive mode lock. */
 UNIV_INLINE
@@ -227,22 +228,22 @@
 	,ulint		pass	/* in: pass value; != 0, if the lock may have
 				been passed to another thread to unlock */
 #endif
-	);
+	, char* lock_name);
 /***********************************************************************
 Releases an exclusive mode lock. */
 
 #ifdef UNIV_SYNC_DEBUG
-#define rw_lock_x_unlock(L)    rw_lock_x_unlock_func(L, 0)
+#define rw_lock_x_unlock(L)    rw_lock_x_unlock_func(L, 0, #L)
 #else
-#define rw_lock_x_unlock(L)    rw_lock_x_unlock_func(L)
+#define rw_lock_x_unlock(L)    rw_lock_x_unlock_func(L, #L)
 #endif
 /***********************************************************************
 Releases an exclusive mode lock. */
 
 #ifdef UNIV_SYNC_DEBUG
-#define rw_lock_x_unlock_gen(L, P)    rw_lock_x_unlock_func(L, P)
+#define rw_lock_x_unlock_gen(L, P)    rw_lock_x_unlock_func(L, P, #L)
 #else
-#define rw_lock_x_unlock_gen(L, P)    rw_lock_x_unlock_func(L)
+#define rw_lock_x_unlock_gen(L, P)    rw_lock_x_unlock_func(L, #L)
 #endif
 /**********************************************************************
 Low-level function which locks an rw-lock in s-mode when we know that it
@@ -457,6 +458,13 @@
 	ulint	last_s_line;	/* Line number where last time s-locked */
 	ulint	last_x_line;	/* Line number where last time x-locked */
 	ulint	magic_n;
+  ulonglong lswork_time; /* time between enter - exit */
+  ulonglong lswait_time; /* waiting time */
+  ulonglong lxwork_time; /* time between enter - exit */
+  ulonglong lxwait_time; /* waiting time */
+  ulint lx_count;
+  ulint ls_count;
+  ulonglong lx_start_work_time;
 };
 
 #define	RW_LOCK_MAGIC_N	22643

--- 1.9/innobase/include/sync0rw.ic	2004-05-27 14:03:51 +02:00
+++ 1.10/innobase/include/sync0rw.ic	2005-06-10 15:40:49 +02:00
@@ -224,9 +224,10 @@
 	ulint		pass,	/* in: pass value; != 0, if the lock will
 				be passed to another thread to unlock */
 	const char*	file_name,/* in: file name where lock requested */
-	ulint		line)	/* in: line where requested */
+	ulint		line, char *lock_name)	/* in: line where requested */
 {
-	/* NOTE: As we do not know the thread ids for threads which have
+
+  /* NOTE: As we do not know the thread ids for threads which have
 	s-locked a latch, and s-lockers will be served only after waiting
 	x-lock requests have been fulfilled, then if this thread already
 	owns an s-lock here, it may end up in a deadlock with another thread
@@ -241,6 +242,12 @@
 	ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
 #endif /* UNIV_SYNC_DEBUG */
 
+/*  fprintf(stderr,
+"Thread %lu S_LOCK at %s cfile %s cline %lu \n",
+  (ulong) os_thread_pf(os_thread_get_curr_id()), lock_name,
+  file_name, line);
+*/
+  lock->ls_count++;
 	mutex_enter(rw_lock_get_mutex(lock));
 
 	if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
@@ -251,8 +258,10 @@
 		/* Did not succeed, try spin wait */
 		mutex_exit(rw_lock_get_mutex(lock));
 
+
 		rw_lock_s_lock_spin(lock, pass, file_name, line);
 
+
 		return;
 	}
 }
@@ -351,7 +360,7 @@
 	,ulint		pass	/* in: pass value; != 0, if the lock may have
 				been passed to another thread to unlock */
 #endif
-	)
+	, char* lock_name)
 {
 	mutex_t*	mutex	= &(lock->mutex);
 	ibool		sg 	= FALSE;
@@ -388,6 +397,10 @@
 #ifdef UNIV_SYNC_PERF_STAT
 	rw_s_exit_count++;
 #endif
+/*  fprintf(stderr,
+"Thread %lu S_LOCK unlock at %s \n",
+  (ulong) os_thread_pf(os_thread_get_curr_id()), lock_name);
+*/
 }
 
 /**********************************************************************
@@ -427,9 +440,13 @@
 	,ulint		pass	/* in: pass value; != 0, if the lock may have
 				been passed to another thread to unlock */
 #endif
-	)
+	, char* lock_name)
 {
 	ibool	sg 	= FALSE;
+  ib_longlong lstart_time = 0, lfinish_time; /* for timing os_wait */
+  ulint ltime_diff;
+  ulint sec;
+  ulint ms;
 
         /* Acquire the mutex protecting the rw-lock fields */
 	mutex_enter(&(lock->mutex));
@@ -455,7 +472,13 @@
 	       	sg = TRUE;
 		rw_lock_set_waiters(lock, 0);
 	}
-	
+
+  ut_usectime(&sec, &ms);
+  lfinish_time= (ib_longlong)sec * 1000000 + ms;
+
+  ltime_diff= (ulint) (lfinish_time - lock->lx_start_work_time);
+  lock->lxwork_time += ltime_diff;
+
 	mutex_exit(&(lock->mutex));
 
 	if (sg == TRUE) {
@@ -467,6 +490,10 @@
 #ifdef UNIV_SYNC_PERF_STAT
 	rw_x_exit_count++;
 #endif
+  /*fprintf(stderr,
+"Thread %lu X_LOCK unlock at %s \n",
+  (ulong) os_thread_pf(os_thread_get_curr_id()), lock_name);
+*/
 }
 
 /**********************************************************************

--- 1.19/innobase/sync/sync0rw.c	2005-02-04 15:25:04 +01:00
+++ 1.20/innobase/sync/sync0rw.c	2005-06-10 15:40:49 +02:00
@@ -128,6 +128,12 @@
 	lock->last_x_file_name = "not yet reserved";
 	lock->last_s_line = 0;
 	lock->last_x_line = 0;
+  lock->lswork_time= 0;
+  lock->lswait_time= 0;
+  lock->lxwork_time= 0;
+  lock->lxwait_time= 0;
+  lock->lx_count= 0;
+  lock->ls_count= 0;
 
 	mutex_enter(&rw_lock_list_mutex);
 	
@@ -221,9 +227,21 @@
 {
         ulint    index;	/* index of the reserved wait cell */
         ulint    i;   	/* spin round count */
+        ib_longlong lstart_time = 0, lfinish_time; /* for timing os_wait */
+        ulint ltime_diff;
+        ulint sec;
+        ulint ms;
         
         ut_ad(rw_lock_validate(lock));
 
+/*        fprintf(stderr,
+      "Thread %lu rw_lock_s_lock_spin enter rw-s-lock at %p cfile %s cline %lu \n",
+        (ulong) os_thread_pf(os_thread_get_curr_id()), lock,
+        file_name, line);
+*/
+        ut_usectime(&sec, &ms);
+        lstart_time= (ib_longlong)sec * 1000000 + ms;
+
 lock_loop:
 	rw_s_spin_wait_count++;
 
@@ -255,7 +273,15 @@
         /* We try once again to obtain the lock */
 
 	if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-		mutex_exit(rw_lock_get_mutex(lock));
+
+    ut_usectime(&sec, &ms);
+    lfinish_time= (ib_longlong)sec * 1000000 + ms;
+
+    ltime_diff= (ulint) (lfinish_time - lstart_time);
+    lock->lswait_time += ltime_diff;
+
+    mutex_exit(rw_lock_get_mutex(lock));
+
 
 		return; /* Success */
 	} else {
@@ -433,14 +459,27 @@
 	ulint		pass,	/* in: pass value; != 0, if the lock will
 				be passed to another thread to unlock */
 	const char*	file_name,/* in: file name where lock requested */
-	ulint		line)	/* in: line where requested */
+	ulint		line, char* lock_name)	/* in: line where requested */
 {
         ulint	index;  /* index of the reserved wait cell */
         ulint	state;	/* lock state acquired */
         ulint	i;	/* spin round count */
+        ib_longlong lstart_time = 0, lfinish_time; /* for timing os_wait */
+        ulint ltime_diff;
+        ulint sec;
+        ulint ms;
         
         ut_ad(rw_lock_validate(lock));
 
+/*        fprintf(stderr,
+        "Thread %lu X_LOCK at %s cfile %s cline %lu \n",
+        (ulong) os_thread_pf(os_thread_get_curr_id()), lock_name,
+        file_name, line);
+*/
+
+        ut_usectime(&sec, &ms);
+        lstart_time= (ib_longlong)sec * 1000000 + ms;
+        lock->lx_count++;
 lock_loop:
         /* Acquire the mutex protecting the rw-lock fields */
 	mutex_enter_fast(&(lock->mutex));
@@ -451,7 +490,7 @@
         
 	if (state == RW_LOCK_EX) {
 
-		return;	/* Locking succeeded */
+		goto finish;	/* Locking succeeded */
 
 	} else if (state == RW_LOCK_NOT_LOCKED) {
 
@@ -511,8 +550,8 @@
 	if (state == RW_LOCK_EX) {
 		mutex_exit(rw_lock_get_mutex(lock));
 
-		return;	/* Locking succeeded */
-	}
+		goto finish;	/* Locking succeeded */
+	}                           
 
 	rw_x_system_call_count++;
 
@@ -538,6 +577,15 @@
         sync_array_wait_event(sync_primary_wait_array, index);
 
         goto lock_loop;
+
+finish:
+    ut_usectime(&sec, &ms);
+    lfinish_time= (ib_longlong)sec * 1000000 + ms;
+
+    ltime_diff= (ulint) (lfinish_time - lstart_time);
+    lock->lxwait_time += ltime_diff;
+    lock->lx_start_work_time= lfinish_time;
+return;
 }
 
 #ifdef UNIV_SYNC_DEBUG

--- 1.210/sql/ha_innodb.cc	2005-06-10 07:18:41 +02:00
+++ 1.211/sql/ha_innodb.cc	2005-06-10 15:40:49 +02:00
@@ -6269,12 +6269,22 @@
   Protocol        *protocol= thd->protocol;
   List<Item> field_list;
   mutex_t*  mutex;
+  rw_lock_t*          lock;
   ulint   rw_lock_count= 0;
   ulint   rw_lock_count_spin_loop= 0;
   ulint   rw_lock_count_spin_rounds= 0;
   ulint   rw_lock_count_os_wait= 0;
   ulint   rw_lock_count_os_yield= 0;
   ulonglong rw_lock_wait_time= 0;
+   char* current_name;
+   char* current_fname;
+   uint first_row;
+   ulonglong sum_s_wait= 0;
+   ulonglong sum_s_work= 0;
+   ulonglong sum_x_wait= 0;
+   ulonglong sum_x_work= 0;
+   ulint x_count= 0;
+   ulint s_count= 0;
 
    ulint   i= 0;
   
@@ -6338,6 +6348,78 @@
 
     mutex = UT_LIST_GET_NEXT(list, mutex);
   }
+
+  lock = UT_LIST_GET_FIRST(rw_lock_list);
+  current_name= "";
+  first_row= 1;
+  sum_s_wait= 0;
+  sum_s_work= 0;
+  sum_x_wait= 0;
+  sum_x_work= 0;
+
+  x_count= 0;
+  s_count= 0;
+
+  while ( lock != NULL )
+  {
+//    fprintf(stderr, "curname %s %s\n", current_name, lock->mutex.cmutex_name);
+        if (strcmp(current_name, lock->mutex.cmutex_name) != 0)
+        {
+          if (!first_row)
+          {
+            protocol->prepare_for_resend();
+            protocol->store(current_name, system_charset_info);
+            protocol->store(current_fname, system_charset_info);
+            protocol->store((ulonglong)x_count);
+            protocol->store((ulonglong)sum_x_work/1000);
+            protocol->store((ulonglong)sum_x_wait/1000);
+            protocol->store((ulonglong)s_count);
+            protocol->store((ulonglong)sum_s_work/1000);
+            protocol->store((ulonglong)sum_s_wait/1000);
+            if (protocol->write())
+            {
+              DBUG_RETURN(1);
+            }
+          }
+
+          first_row= 0;
+  
+            current_name= (char *)lock->mutex.cmutex_name;
+            current_fname= (char *) lock->cfile_name;
+            sum_s_work = lock->lswork_time;
+            sum_s_wait = lock->lswait_time;
+            sum_x_work = lock->lxwork_time;
+            sum_x_wait = lock->lxwait_time;
+            x_count= lock->lx_count;
+            s_count= lock->ls_count;
+        }
+        else
+        {
+          sum_s_work += lock->lswork_time;
+          sum_s_wait += lock->lswait_time;
+          sum_x_work += lock->lxwork_time;
+          sum_x_wait += lock->lxwait_time;
+          x_count += lock->lx_count;
+          s_count += lock->ls_count;
+
+        }
+
+    lock = UT_LIST_GET_NEXT(list, lock);
+  }
+  protocol->prepare_for_resend();
+  protocol->store(current_name, system_charset_info);
+  protocol->store(current_fname, system_charset_info);
+  protocol->store((ulonglong)x_count);
+  protocol->store((ulonglong)sum_x_work/1000);
+  protocol->store((ulonglong)sum_x_wait/1000);
+  protocol->store((ulonglong)s_count);
+  protocol->store((ulonglong)sum_s_work/1000);
+  protocol->store((ulonglong)sum_s_wait/1000);
+  if (protocol->write())
+  {                                    
+    DBUG_RETURN(1);
+  }
+
 
   protocol->prepare_for_resend();
   protocol->store("rw_lock_mutexes", system_charset_info);
Thread
bk commit into 5.0-hp tree (vtkachenko:1.1944)Vadim Tkachenko10 Jun