]> granicus.if.org Git - postgresql/commitdiff
Allow MEMSET_LOOP_LIMIT to be set on a per-platform basis, and turn off
authorBruce Momjian <bruce@momjian.us>
Fri, 3 Feb 2006 13:53:15 +0000 (13:53 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 3 Feb 2006 13:53:15 +0000 (13:53 +0000)
MemSet on AIX by setting MEMSET_LOOP_LIMIT to zero.

Add optimization to skip MemSet tests in MEMSET_LOOP_LIMIT == 0 case and
just call memset() directly.

configure
configure.in
src/include/c.h
src/include/pg_config.h.in
src/template/aix

index 0c6fc286100b2b01eb0eee4e060578068911287c..0cd5260f30f55dcdec67b3229fa15d97d5732101 100755 (executable)
--- a/configure
+++ b/configure
@@ -21516,6 +21516,17 @@ _ACEOF
 SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
 
 
+# If not set in template file, set bytes to use libc memset()
+if test x"$MEMSET_LOOP_LIMIT" = x"" ; then
+  MEMSET_LOOP_LIMIT=1024
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define MEMSET_LOOP_LIMIT ${MEMSET_LOOP_LIMIT}
+_ACEOF
+
+
+
 if test "$enable_nls" = yes ; then
 
   echo "$as_me:$LINENO: checking for library containing gettext" >&5
index 4edd00e11f49d131b7558cba066686993e6dd4ec..b2094d0d3e91a70f67aaaf16b1f2fc8dc5e838af 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.443 2006/01/17 23:52:30 tgl Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.444 2006/02/03 13:53:15 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -1249,6 +1249,13 @@ AC_DEFINE(USE_SYSV_SHARED_MEMORY, 1, [Define to select SysV-style shared memory.
 SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
 
 
+# If not set in template file, set bytes to use libc memset()
+if test x"$MEMSET_LOOP_LIMIT" = x"" ; then
+  MEMSET_LOOP_LIMIT=1024
+fi
+AC_DEFINE_UNQUOTED(MEMSET_LOOP_LIMIT, ${MEMSET_LOOP_LIMIT}, [Define bytes to use libc memset().])
+
+
 if test "$enable_nls" = yes ; then
   PGAC_CHECK_GETTEXT
 fi
index 797f2f8438be891364b09b512ad178abf5739ab2..8c3881bf9e0bd057b35adcaa5cf93f9d9335116b 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/c.h,v 1.194 2006/01/05 03:01:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.195 2006/02/03 13:53:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -614,9 +614,7 @@ typedef NameData *Name;
  *     overhead.       However, we have also found that the loop is faster than
  *     native libc memset() on some platforms, even those with assembler
  *     memset() functions.  More research needs to be done, perhaps with
- *     platform-specific MEMSET_LOOP_LIMIT values or tests in configure.
- *
- *     bjm 2002-10-08
+ *     MEMSET_LOOP_LIMIT tests in configure.
  */
 #define MemSet(start, val, len) \
        do \
@@ -629,7 +627,12 @@ typedef NameData *Name;
                if ((((long) _vstart) & INT_ALIGN_MASK) == 0 && \
                        (_len & INT_ALIGN_MASK) == 0 && \
                        _val == 0 && \
-                       _len <= MEMSET_LOOP_LIMIT) \
+                       _len <= MEMSET_LOOP_LIMIT && \
+                       /* \
+                        *      If MEMSET_LOOP_LIMIT == 0, optimizer should find \
+                        *      the whole "if" false at compile time. \
+                        */ \
+                       MEMSET_LOOP_LIMIT != 0) \
                { \
                        int32 *_start = (int32 *) _vstart; \
                        int32 *_stop = (int32 *) ((char *) _start + _len); \
@@ -640,8 +643,6 @@ typedef NameData *Name;
                        memset(_vstart, _val, _len); \
        } while (0)
 
-#define MEMSET_LOOP_LIMIT  1024
-
 /*
  * MemSetAligned is the same as MemSet except it omits the test to see if
  * "start" is word-aligned.  This is okay to use if the caller knows a-priori
@@ -657,7 +658,8 @@ typedef NameData *Name;
 \
                if ((_len & INT_ALIGN_MASK) == 0 && \
                        _val == 0 && \
-                       _len <= MEMSET_LOOP_LIMIT) \
+                       _len <= MEMSET_LOOP_LIMIT && \
+                       MEMSET_LOOP_LIMIT != 0) \
                { \
                        int32 *_stop = (int32 *) ((char *) _start + _len); \
                        while (_start < _stop) \
@@ -679,6 +681,7 @@ typedef NameData *Name;
 #define MemSetTest(val, len) \
        ( ((len) & INT_ALIGN_MASK) == 0 && \
        (len) <= MEMSET_LOOP_LIMIT && \
+       MEMSET_LOOP_LIMIT != 0 && \
        (val) == 0 )
 
 #define MemSetLoop(start, val, len) \
index 2c24ce3d811f69876caebe79da21b2a2f1b0e815..8db19b4c48318b84be975db8ced2923ccf06b474 100644 (file)
 /* Define as the maximum alignment requirement of any C data type. */
 #undef MAXIMUM_ALIGNOF
 
+/* Define bytes to use libc memset(). */
+#undef MEMSET_LOOP_LIMIT
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
index 48f1110f3e8a59d9ec2f8fd8a669a81ff54130b9..d875a08083c0a76bac03daebe21fb5f40f0db5ce 100644 (file)
@@ -8,3 +8,7 @@ if test "$GCC" != yes ; then
       ;;
   esac
 fi
+
+# native memset() is faster, 2006-02-03
+# XLC 6.0, (IBM's cc), tested on AIX 5.2 and 5.1
+MEMSET_LOOP_LIMIT=0