List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:November 9 2010 10:24am
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3974)
View as plain text  
#At file:///home/msvensson/mysql/7.0/ based on revid:magnus.blaudd@stripped

 3974 Magnus Blåudd	2010-11-09
      ndb
       - add NDB_PREFETCH_READ and NDB_PREFETCH write macros
         to ndb_global.h
       - remove "unused" prefetch.h file, the macros where referenced but
         never enabled the prefetch
       - change the places that used old prefetch to use new
       - make mt.cpp include ndb_global.h so it get all the same defines
        as other code

    removed:
      storage/ndb/include/portlib/prefetch.h
    modified:
      storage/ndb/include/ndb_global.h
      storage/ndb/src/kernel/vm/FastScheduler.cpp
      storage/ndb/src/kernel/vm/FastScheduler.hpp
      storage/ndb/src/kernel/vm/mt.cpp
=== modified file 'storage/ndb/include/ndb_global.h'
--- a/storage/ndb/include/ndb_global.h	2010-10-28 07:45:21 +0000
+++ b/storage/ndb/include/ndb_global.h	2010-11-09 10:24:00 +0000
@@ -260,4 +260,24 @@ C_MODE_END
 */
 #define require(v) require_exit_or_core_with_printer((v), 0, 0)
 
+/*
+  The macros below are useful in optimising places where it has been
+  discovered that cache misses stall the process and where a prefetch
+  of the cache line can improve matters. This is available in GCC 3.1.1
+  and later versions.
+  PREFETCH_READ says that addr is going to be used for reading and that
+  it is to be kept in caches if possible for a while
+  PREFETCH_WRITE also says that the item to be cached is likely to be
+  updated.
+  For more input see GCC manual (available in GCC 3.1.1 and later)
+*/
+
+#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
+#define NDB_PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3)
+#define NDB_PREFETCH_WRITE(addr) __builtin_prefetch(addr, 1, 3)
+#else
+#define NDB_PREFETCH_READ(addr)
+#define NDB_PREFETCH_READ_LOCALITY(addr, locality)
+#endif
+
 #endif

=== removed file 'storage/ndb/include/portlib/prefetch.h'
--- a/storage/ndb/include/portlib/prefetch.h	2010-11-09 06:49:19 +0000
+++ b/storage/ndb/include/portlib/prefetch.h	1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-/*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
-*/
-
-#ifndef PREFETCH_H
-#define PREFETCH_H
-
-#ifdef NDB_FORTE6
-#include <sun_prefetch.h>
-#endif
-
-#ifdef USE_PREFETCH
-#define PREFETCH(addr) prefetch(addr)
-#else
-#define PREFETCH(addr)
-#endif
-
-#ifdef USE_PREFETCH
-#define WRITEHINT(addr) writehint(addr)
-#else
-#define WRITEHINT(addr)
-#endif
-
-#ifdef NDB_FORTE6
-#pragma optimize("", off)
-#endif
-inline void prefetch(void* p)
-{
-#ifdef NDB_ALPHA
-   __asm(" ldl r31,0(a0);", p);
-#endif /* NDB_ALPHA */
-#ifdef NDB_FORTE6
-  sparc_prefetch_read_once(p);
-#else 
-  (void)p;
-#endif
-}
-
-inline void writehint(void* p)
-{
-#ifdef NDB_ALPHA
-   __asm(" wh64 (a0);", p);
-#endif /* NDB_ALPHA */
-#ifdef NDB_FORTE6
-  sparc_prefetch_write_once(p);
-#else
-  (void)p;
-#endif
-}
-#ifdef NDB_FORTE6
-#pragma optimize("", on)
-#endif
-
-#endif
-

=== modified file 'storage/ndb/src/kernel/vm/FastScheduler.cpp'
--- a/storage/ndb/src/kernel/vm/FastScheduler.cpp	2010-08-17 09:54:53 +0000
+++ b/storage/ndb/src/kernel/vm/FastScheduler.cpp	2010-11-09 10:24:00 +0000
@@ -265,8 +265,8 @@ APZJobBuffer::retrieve(Signal* signal)
       // read both the first cache line and the next 64 byte
       // entry
       //---------------------------------------------------------
-      PREFETCH((void*)&buffer[rPtr]);
-      PREFETCH((void*)(((char*)&buffer[rPtr]) + 64));
+      NDB_PREFETCH_READ((void*)&buffer[rPtr]);
+      NDB_PREFETCH_READ((void*)(((char*)&buffer[rPtr]) + 64));
       return gsnbnr;
     } else {
       bnr_error();
@@ -338,9 +338,8 @@ APZJobBuffer::insert(const SignalHeader 
     // write both the first cache line and the next 64 byte
     // entry
     //---------------------------------------------------------
-    WRITEHINT((void*)&buffer[wPtr]);
-    WRITEHINT((void*)(((char*)&buffer[wPtr]) + 64));
-    
+    NDB_PREFETCH_WRITE((void*)&buffer[wPtr]);
+    NDB_PREFETCH_WRITE((void*)(((char*)&buffer[wPtr]) + 64));
   } else {
     jbuf_error();
   }//if

=== modified file 'storage/ndb/src/kernel/vm/FastScheduler.hpp'
--- a/storage/ndb/src/kernel/vm/FastScheduler.hpp	2009-10-21 13:23:05 +0000
+++ b/storage/ndb/src/kernel/vm/FastScheduler.hpp	2010-11-09 10:24:00 +0000
@@ -27,7 +27,6 @@
 #include <ErrorHandlingMacros.hpp>
 #include <GlobalData.hpp>
 #include <TransporterDefinitions.hpp>
-#include <prefetch.h>
 
 #define MAX_OCCUPANCY 1024
 
@@ -348,8 +347,8 @@ APZJobBuffer::insert(Signal* signal,
     // write both the first cache line and the next 64 byte
     // entry
     //---------------------------------------------------------
-    WRITEHINT((void*)&buffer[wPtr]);
-    WRITEHINT((void*)(((char*)&buffer[wPtr]) + 64));
+    NDB_PREFETCH_WRITE((void*)&buffer[wPtr]);
+    NDB_PREFETCH_WRITE((void*)(((char*)&buffer[wPtr]) + 64));
   } else {
     jbuf_error();
   }//if

=== modified file 'storage/ndb/src/kernel/vm/mt.cpp'
--- a/storage/ndb/src/kernel/vm/mt.cpp	2010-09-22 08:48:10 +0000
+++ b/storage/ndb/src/kernel/vm/mt.cpp	2010-11-09 10:24:00 +0000
@@ -13,19 +13,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#ifndef _WIN32
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/time.h>
-#endif
-#include <errno.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
+#include <ndb_global.h>
 
 #include <VMSignal.hpp>
 #include <kernel_types.h>
@@ -2392,8 +2380,8 @@ execute_signals(thr_data *selfptr, thr_j
      * (Though on Intel Core 2, they do not give much speedup, as apparently
      * the hardware prefetcher is already doing a fairly good job).
      */
-    PREFETCH_READ (read_buffer->m_data + read_pos + 16);
-    PREFETCH_WRITE ((Uint32 *)&sig->header + 16);
+    NDB_PREFETCH_READ (read_buffer->m_data + read_pos + 16);
+    NDB_PREFETCH_WRITE ((Uint32 *)&sig->header + 16);
 
     /* Now execute the signal. */
     SignalHeader* s =
@@ -2402,7 +2390,7 @@ execute_signals(thr_data *selfptr, thr_j
     Uint32 siglen = (sizeof(*s)>>2) + s->theLength;
     if(siglen>16)
     {
-      PREFETCH_READ (read_buffer->m_data + read_pos + 32);
+      NDB_PREFETCH_READ (read_buffer->m_data + read_pos + 32);
     }
     Uint32 bno = blockToMain(s->theReceiversBlockNumber);
     Uint32 ino = map_instance(s);

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20101109102400-ukbklzwssmdgu4oc.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3974) Magnus Blåudd9 Nov