summaryrefslogtreecommitdiff
path: root/mysys/ptr_cmp.c
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2012-03-25 19:27:24 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2012-03-25 19:27:24 +0200
commit1be4b121d514393e2305273436cde25acbf1a25d (patch)
treeee23252d3270c8914c5a805d1b1e993d8afdb2ad /mysys/ptr_cmp.c
parent99aa3d465e9141fdcc7bbd93d4c7f6cfecb27165 (diff)
downloadmariadb-git-1be4b121d514393e2305273436cde25acbf1a25d.tar.gz
Small Windows specific performance fixes:
- Use native memcmp() supplied with C runtime instead of hand-unrolled loop ptr_compare_N loop Prior to fix ptr_compare_0() has 3.7% samples in OLTP-RO in-memory. Fix brings this down to 1.8% (all memcmp samples) - Innodb : fix UT_RELAX_CPU to be defined as YieldProcessor, as was also originally intended (but intention was lost in the #ifdef maze This reduces number of ut_delay() samples in profile from 1.5% to 0.5%
Diffstat (limited to 'mysys/ptr_cmp.c')
-rw-r--r--mysys/ptr_cmp.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c
index 6f9ab13c82b..a481b4d961c 100644
--- a/mysys/ptr_cmp.c
+++ b/mysys/ptr_cmp.c
@@ -21,17 +21,23 @@
#include "mysys_priv.h"
#include <myisampack.h>
-
-#ifdef __sun
/*
- * On Solaris, memcmp() is normally faster than the unrolled ptr_compare_N
+ * On some platforms, memcmp() is faster than the unrolled ptr_compare_N
* functions, as memcmp() is usually a platform-specific implementation
- * written in assembler, provided in /usr/lib/libc/libc_hwcap*.so.1.
- * This implementation is also usually faster than the built-in memcmp
- * supplied by GCC, so it is recommended to build with "-fno-builtin-memcmp"
- * in CFLAGS if building with GCC on Solaris.
+ * written in assembler. for example one in /usr/lib/libc/libc_hwcap*.so.1.
+ * on Solaris, or on Windows inside C runtime linrary.
+ *
+ * On Solaris, native implementation is also usually faster than the
+ * built-in memcmp supplied by GCC, so it is recommended to build
+ * with "-fno-builtin-memcmp"in CFLAGS if building with GCC on Solaris.
*/
+#if defined (__sun) || defined (_WIN32)
+#define USE_NATIVE_MEMCMP 1
+#endif
+
+#ifdef USE_NATIVE_MEMCMP
+
#include <string.h>
static int native_compare(size_t *length, unsigned char **a, unsigned char **b)
@@ -39,7 +45,7 @@ static int native_compare(size_t *length, unsigned char **a, unsigned char **b)
return memcmp(*a, *b, *length);
}
-#else /* __sun */
+#else /* USE_NATIVE_MEMCMP */
static int ptr_compare(size_t *compare_length, uchar **a, uchar **b);
static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b);
@@ -50,7 +56,7 @@ static int ptr_compare_3(size_t *compare_length, uchar **a, uchar **b);
/* Get a pointer to a optimal byte-compare function for a given size */
-#ifdef __sun
+#ifdef USE_NATIVE_MEMCMP
qsort2_cmp get_ptr_compare (size_t size __attribute__((unused)))
{
return (qsort2_cmp) native_compare;
@@ -68,7 +74,7 @@ qsort2_cmp get_ptr_compare (size_t size)
}
return 0; /* Impossible */
}
-#endif /* __sun */
+#endif /* USE_NATIVE_MEMCMP */
/*
@@ -78,7 +84,7 @@ qsort2_cmp get_ptr_compare (size_t size)
#define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N]
-#ifndef __sun
+#ifndef USE_NATIVE_MEMCMP
static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
{