MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mhansson Date:February 20 2008 12:52pm
Subject:bk commit into 5.0 tree (mhansson:1.2594) BUG#14638
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of mhansson.  When mhansson 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@stripped, 2008-02-20 13:51:23+01:00, mhansson@riffraff.(none) +4 -0
  Bug#14638: ptr_compare processes data only byte wise
  
  The comparison function for memory regions is not the optimal way to 
  compare memory regions on modern architectures. 
  This patch replaces the hand-optimized function with a wrapper for
  memcmp, which is inlined in gcc versions >= 4.1.2.

  include/my_sys.h@stripped, 2008-02-20 13:51:22+01:00, mhansson@riffraff.(none) +1 -1
    Bug#14638: Removed get_ptr_compare and added the memcmp wrapper.

  mysys/mf_sort.c@stripped, 2008-02-20 13:51:22+01:00, mhansson@riffraff.(none) +2 -1
    Bug#14638: Removed reference to get_ptr_compare.

  mysys/ptr_cmp.c@stripped, 2008-02-20 13:51:22+01:00, mhansson@riffraff.(none) +3 -128
    Bug#14638: Replaced all hand-optimized functions with a memcmp wrapper.

  sql/filesort.cc@stripped, 2008-02-20 13:51:22+01:00, mhansson@riffraff.(none) +1 -1
    Bug#14638: Removed reference to get_ptr_compare.

diff -Nrup a/include/my_sys.h b/include/my_sys.h
--- a/include/my_sys.h	2007-12-05 04:07:00 +01:00
+++ b/include/my_sys.h	2008-02-20 13:51:22 +01:00
@@ -715,7 +715,7 @@ extern qsort_t my_qsort(void *base_ptr, 
                         qsort_cmp cmp);
 extern qsort_t my_qsort2(void *base_ptr, size_t total_elems, size_t size,
                          qsort2_cmp cmp, void *cmp_argument);
-extern qsort2_cmp get_ptr_compare(uint);
+extern int ptr_compare(uint *compare_length, uchar **a, uchar **b);
 void my_store_ptr(byte *buff, uint pack_length, my_off_t pos);
 my_off_t my_get_ptr(byte *ptr, uint pack_length);
 extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
diff -Nrup a/mysys/mf_sort.c b/mysys/mf_sort.c
--- a/mysys/mf_sort.c	2007-10-17 18:08:53 +02:00
+++ b/mysys/mf_sort.c	2008-02-20 13:51:22 +01:00
@@ -35,7 +35,8 @@ void my_string_ptr_sort(void *base, uint
     if (size && items)
     {
       uint size_arg=size;
-      my_qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg);
+      my_qsort2(base,items, sizeof(byte*), (qsort2_cmp)ptr_compare,
+                (void*) &size_arg);
     }
   }
 }
diff -Nrup a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c
--- a/mysys/ptr_cmp.c	2007-02-22 15:59:54 +01:00
+++ b/mysys/ptr_cmp.c	2008-02-20 13:51:22 +01:00
@@ -21,136 +21,11 @@
 
 #include "mysys_priv.h"
 #include <myisampack.h>
+#include <string.h>
 
-static int ptr_compare(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_0(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_1(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_2(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_3(uint *compare_length, uchar **a, uchar **b);
-
-	/* Get a pointer to a optimal byte-compare function for a given size */
-
-qsort2_cmp get_ptr_compare (uint size)
-{
-  if (size < 4)
-    return (qsort2_cmp) ptr_compare;
-  switch (size & 3) {
-    case 0: return (qsort2_cmp) ptr_compare_0;
-    case 1: return (qsort2_cmp) ptr_compare_1;
-    case 2: return (qsort2_cmp) ptr_compare_2;
-    case 3: return (qsort2_cmp) ptr_compare_3;
-    }
-  return 0;					/* Impossible */
-}
-
-
-	/*
-	  Compare to keys to see witch is smaller.
-	  Loop unrolled to make it quick !!
-	*/
-
-#define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N]
-
-static int ptr_compare(uint *compare_length, uchar **a, uchar **b)
-{
-  reg3 int length= *compare_length;
-  reg1 uchar *first,*last;
-
-  first= *a; last= *b;
-  while (--length)
-  {
-    if (*first++ != *last++)
-      return (int) first[-1] - (int) last[-1];
-  }
-  return (int) first[0] - (int) last[0];
-}
-
-
-static int ptr_compare_0(uint *compare_length,uchar **a, uchar **b)
+int ptr_compare(uint *compare_length, uchar **a, uchar **b)
 {
-  reg3 int length= *compare_length;
-  reg1 uchar *first,*last;
-
-  first= *a; last= *b;
- loop:
-  cmp(0);
-  cmp(1);
-  cmp(2);
-  cmp(3);
-  if ((length-=4))
-  {
-    first+=4;
-    last+=4;
-    goto loop;
-  }
-  return (0);
-}
-
-
-static int ptr_compare_1(uint *compare_length,uchar **a, uchar **b)
-{
-  reg3 int length= *compare_length-1;
-  reg1 uchar *first,*last;
-
-  first= *a+1; last= *b+1;
-  cmp(-1);
- loop:
-  cmp(0);
-  cmp(1);
-  cmp(2);
-  cmp(3);
-  if ((length-=4))
-  {
-    first+=4;
-    last+=4;
-    goto loop;
-  }
-  return (0);
-}
-
-static int ptr_compare_2(uint *compare_length,uchar **a, uchar **b)
-{
-  reg3 int length= *compare_length-2;
-  reg1 uchar *first,*last;
-
-  first= *a +2 ; last= *b +2;
-  cmp(-2);
-  cmp(-1);
- loop:
-  cmp(0);
-  cmp(1);
-  cmp(2);
-  cmp(3);
-  if ((length-=4))
-  {
-    first+=4;
-    last+=4;
-    goto loop;
-  }
-  return (0);
-}
-
-static int ptr_compare_3(uint *compare_length,uchar **a, uchar **b)
-{
-  reg3 int length= *compare_length-3;
-  reg1 uchar *first,*last;
-
-  first= *a +3 ; last= *b +3;
-  cmp(-3);
-  cmp(-2);
-  cmp(-1);
- loop:
-  cmp(0);
-  cmp(1);
-  cmp(2);
-  cmp(3);
-  if ((length-=4))
-  {
-    first+=4;
-    last+=4;
-    goto loop;
-  }
-  return (0);
+  return memcmp(*a, *b, (size_t)*compare_length);
 }
 
 void my_store_ptr(byte *buff, uint pack_length, my_off_t pos)
diff -Nrup a/sql/filesort.cc b/sql/filesort.cc
--- a/sql/filesort.cc	2008-01-10 16:52:24 +01:00
+++ b/sql/filesort.cc	2008-02-20 13:51:22 +01:00
@@ -1096,7 +1096,7 @@ int merge_buffers(SORTPARAM *param, IO_C
   }
   else
   {
-    cmp= get_ptr_compare(sort_length);
+    cmp= (qsort2_cmp)ptr_compare;
     first_cmp_arg= (void*) &sort_length;
   }
   if (init_queue(&queue, (uint) (Tb-Fb)+1, offsetof(BUFFPEK,key), 0,
Thread
bk commit into 5.0 tree (mhansson:1.2594) BUG#14638mhansson20 Feb
  • Re: bk commit into 5.0 tree (mhansson:1.2594) BUG#14638Sergei Golubchik22 Feb