List:Internals« Previous MessageNext Message »
From:Marko Mäkelä Date:June 30 2005 8:15am
Subject:bk commit into 5.0 tree (marko:1.1993)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of marko. When marko 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.1993 05/06/30 11:15:06 marko@stripped +3 -0
  InnoDB: Optimize page_cur_search_with_match().

  innobase/page/page0cur.c
    1.26 05/06/30 11:14:57 marko@stripped +56 -44
    Disable the mode PAGE_CUR_LE_OR_EXTENDS at compile-time
    Disable PAGE_CUR_DBG unless #ifdef UNIV_SEARCH_DEBUG
    
    page_cur_try_search_shortcut(): Optimize the predicates
    (compare the result of page_cmp_dtuple_rec_with_match() against 0,
    use page_rec_is_supremum()).
    
    page_cur_search_with_match(): Compare the result of
    cmp_dtuple_rec_with_match() against zero, add UNIV_LIKELY hints,
    replace duplicated code with gotos.

  innobase/include/page0cur.h
    1.8 05/06/30 11:14:57 marko@stripped +4 -2
    Disable the mode PAGE_CUR_LE_OR_EXTENDS at compile-time
    Do not define PAGE_CUR_DBG unless #ifdef UNIV_SEARCH_DEBUG

  innobase/btr/btr0cur.c
    1.53 05/06/30 11:14:57 marko@stripped +6 -2
    Disable the mode PAGE_CUR_LE_OR_EXTENDS at compile-time

# 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:	marko
# Host:	hundin.mysql.fi
# Root:	/home/marko/mysql-5.0-current

--- 1.52/innobase/btr/btr0cur.c	Mon Jun 27 18:57:26 2005
+++ 1.53/innobase/btr/btr0cur.c	Thu Jun 30 11:14:57 2005
@@ -316,7 +316,9 @@
 	if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED
 		&& latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
 		&& !estimate
+#ifdef PAGE_CUR_LE_OR_EXTENDS
 		&& mode != PAGE_CUR_LE_OR_EXTENDS
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
 		&& srv_use_adaptive_hash_indexes
 	        && btr_search_guess_on_hash(index, info, tuple, mode,
 						latch_mode, cursor,
@@ -391,8 +393,10 @@
 		break;
 	default:
 		ut_ad(mode == PAGE_CUR_L
-			|| mode == PAGE_CUR_LE
-			|| mode == PAGE_CUR_LE_OR_EXTENDS);
+#ifdef PAGE_CUR_LE_OR_EXTENDS
+			|| mode == PAGE_CUR_LE_OR_EXTENDS
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+			|| mode == PAGE_CUR_LE);
 		page_mode = mode;
 		break;
 	}

--- 1.7/innobase/include/page0cur.h	Mon Apr 25 10:14:26 2005
+++ 1.8/innobase/include/page0cur.h	Thu Jun 30 11:14:57 2005
@@ -26,11 +26,13 @@
 #define	PAGE_CUR_GE	2
 #define	PAGE_CUR_L	3
 #define	PAGE_CUR_LE	4
-#define PAGE_CUR_LE_OR_EXTENDS 5 /* This is a search mode used in
+/*#define PAGE_CUR_LE_OR_EXTENDS 5*/ /* This is a search mode used in
 				 "column LIKE 'abc%' ORDER BY column DESC";
 				 we have to find strings which are <= 'abc' or
 				 which extend it */
-#define	PAGE_CUR_DBG	6
+#ifdef UNIV_SEARCH_DEBUG
+# define PAGE_CUR_DBG	6	/* As PAGE_CUR_LE, but skips search shortcut */
+#endif /* UNIV_SEARCH_DEBUG */
 
 #ifdef PAGE_CUR_ADAPT
 # ifdef UNIV_SEARCH_PERF_STAT

--- 1.25/innobase/page/page0cur.c	Mon Apr 25 10:14:26 2005
+++ 1.26/innobase/page/page0cur.c	Thu Jun 30 11:14:57 2005
@@ -47,7 +47,6 @@
 				not yet completely matched */
 	page_cur_t*	cursor) /* out: page cursor */ 
 {
-	int	cmp;
 	rec_t*	rec;
 	rec_t*	next_rec;
 	ulint	low_match;
@@ -79,9 +78,8 @@
 	up_match = low_match;
 	up_bytes = low_bytes;
 
-	cmp = page_cmp_dtuple_rec_with_match(tuple, rec, offsets, &low_match,
-								&low_bytes);
-	if (cmp == -1) {
+	if (page_cmp_dtuple_rec_with_match(tuple, rec, offsets,
+						&low_match, &low_bytes) < 0) {
 		goto exit_func;
 	}
 
@@ -89,9 +87,8 @@
 	offsets = rec_get_offsets(next_rec, index, offsets,
 				dtuple_get_n_fields(tuple), &heap);
 
-	cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec, offsets,
-						&up_match, &up_bytes);
-	if (cmp != -1) {
+	if (page_cmp_dtuple_rec_with_match(tuple, next_rec, offsets,
+						&up_match, &up_bytes) >= 0) {
 		goto exit_func;
 	}
 
@@ -115,7 +112,7 @@
 	ut_a(*ilow_matched_fields == low_match);
 	ut_a(*ilow_matched_bytes == low_bytes);
 #endif
-	if (next_rec != page_get_supremum_rec(page)) {
+	if (!page_rec_is_supremum(next_rec)) {
 
 		*iup_matched_fields = up_match;
 		*iup_matched_bytes = up_bytes;
@@ -137,6 +134,7 @@
 
 #endif
 
+#ifdef PAGE_CUR_LE_OR_EXTENDS
 /********************************************************************
 Checks if the nth field in a record is a character type field which extends
 the nth field in tuple, i.e., the field is longer or equal in length and has
@@ -185,6 +183,7 @@
 
         return(FALSE);
 }
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
 
 /********************************************************************
 Searches the right position for a page cursor. */
@@ -240,9 +239,14 @@
 	ut_ad(dtuple_validate(tuple));
 	ut_ad(dtuple_check_typed(tuple));
 	ut_ad((mode == PAGE_CUR_L) || (mode == PAGE_CUR_LE)
-	      || (mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE)
-	      || (mode == PAGE_CUR_LE_OR_EXTENDS) || (mode == PAGE_CUR_DBG));
-	      
+#ifdef PAGE_CUR_DBG
+	      || (mode == PAGE_CUR_DBG)
+#endif /* PAGE_CUR_DBG */
+#ifdef PAGE_CUR_LE_OR_EXTENDS
+	      || (mode == PAGE_CUR_LE_OR_EXTENDS)
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+	      || (mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE));
+
 	page_check_dir(page);
 
 #ifdef PAGE_CUR_ADAPT
@@ -261,16 +265,18 @@
 	    		return;
 	    	}
 	}
-/*#ifdef UNIV_SEARCH_DEBUG */
+# ifdef PAGE_CUR_DBG
 	if (mode == PAGE_CUR_DBG) {
 		mode = PAGE_CUR_LE;
 	}
-/*#endif */
+# endif
 #endif	
 
 	/* The following flag does not work for non-latin1 char sets because
 	cmp_full_field does not tell how many bytes matched */
+#ifdef PAGE_CUR_LE_OR_EXTENDS
 	ut_a(mode != PAGE_CUR_LE_OR_EXTENDS); 
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
 
 	/* If mode PAGE_CUR_G is specified, we are trying to position the
 	cursor to answer a query of the form "tuple < X", where tuple is
@@ -308,33 +314,36 @@
 		cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets,
 						&cur_matched_fields,
 						&cur_matched_bytes);
-		if (cmp == 1) {
+		if (UNIV_LIKELY(cmp > 0)) {
+low_slot_match:
 			low = mid;
 			low_matched_fields = cur_matched_fields;
 			low_matched_bytes = cur_matched_bytes;
 
-		} else if (cmp == -1) {
+		} else if (UNIV_LIKELY(cmp /* == -1 */)) {
+#ifdef PAGE_CUR_LE_OR_EXTENDS
 			if (mode == PAGE_CUR_LE_OR_EXTENDS
 			    && page_cur_rec_field_extends(tuple, mid_rec,
 						offsets, cur_matched_fields)) {
-				low = mid;
-				low_matched_fields = cur_matched_fields;
-				low_matched_bytes = cur_matched_bytes;
-			} else {
-				up = mid;
-				up_matched_fields = cur_matched_fields;
-				up_matched_bytes = cur_matched_bytes;
-			}
 
-		} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
-			   || mode == PAGE_CUR_LE_OR_EXTENDS) {
-			low = mid;
-			low_matched_fields = cur_matched_fields;
-			low_matched_bytes = cur_matched_bytes;
-		} else {
+				goto low_slot_match;
+			}
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+up_slot_match:
 			up = mid;
 			up_matched_fields = cur_matched_fields;
 			up_matched_bytes = cur_matched_bytes;
+
+		} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
+#ifdef PAGE_CUR_LE_OR_EXTENDS
+			   || mode == PAGE_CUR_LE_OR_EXTENDS
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+		) {
+
+			goto low_slot_match;
+		} else {
+
+			goto up_slot_match;
 		}
    	}
 
@@ -360,32 +369,35 @@
 		cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets,
 						&cur_matched_fields,
 						&cur_matched_bytes);
-		if (cmp == 1) {
+		if (UNIV_LIKELY(cmp > 0)) {
+low_rec_match:
 			low_rec = mid_rec;
 			low_matched_fields = cur_matched_fields;
 			low_matched_bytes = cur_matched_bytes;
 
-		} else if (cmp == -1) {
+		} else if (UNIV_LIKELY(cmp /* == -1 */)) {
+#ifdef PAGE_CUR_LE_OR_EXTENDS
 			if (mode == PAGE_CUR_LE_OR_EXTENDS
 			    && page_cur_rec_field_extends(tuple, mid_rec,
 						offsets, cur_matched_fields)) {
-				low_rec = mid_rec;
-				low_matched_fields = cur_matched_fields;
-				low_matched_bytes = cur_matched_bytes;
-			} else {
-				up_rec = mid_rec;
-				up_matched_fields = cur_matched_fields;
-				up_matched_bytes = cur_matched_bytes;
+
+				goto low_rec_match;
 			}
-		} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
-			   || mode == PAGE_CUR_LE_OR_EXTENDS) {
-			low_rec = mid_rec;
-			low_matched_fields = cur_matched_fields;
-			low_matched_bytes = cur_matched_bytes;
-		} else {
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+up_rec_match:
 			up_rec = mid_rec;
 			up_matched_fields = cur_matched_fields;
 			up_matched_bytes = cur_matched_bytes;
+		} else if (mode == PAGE_CUR_G || mode == PAGE_CUR_LE
+#ifdef PAGE_CUR_LE_OR_EXTENDS
+			   || mode == PAGE_CUR_LE_OR_EXTENDS
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+		) {
+
+			goto low_rec_match;
+		} else {
+
+			goto up_rec_match;
 		}
    	}
 
Thread
bk commit into 5.0 tree (marko:1.1993)Marko Mäkelä30 Jun