List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:May 25 2011 7:58am
Subject:bzr commit into mysql-5.1-telco-7.0 branch (jonas:4413)
View as plain text  
#At file:///home/jonas/src/telco-7.0/ based on revid:jonas@stripped

 4413 Jonas Oreland	2011-05-25
      ndb - change implementation of DIVERIFY_queue to be a srsw array based queue (easy to make thread safe) instead of linked-list

    modified:
      storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp	2011-05-18 09:07:07 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp	2011-05-25 07:58:32 +0000
@@ -122,7 +122,7 @@ public:
    * ONGOING */
   struct ApiConnectRecord {
     Uint64 apiGci;
-    Uint32 nextApi;
+    Uint32 senderData;
   };
   typedef Ptr<ApiConnectRecord> ApiConnectRecordPtr;
 
@@ -1315,19 +1315,17 @@ private:
   struct DIVERIFY_queue
   {
     DIVERIFY_queue() {
-      cfirstVerifyQueue = clastVerifyQueue = RNIL;
-      cverifyQueueCounter = 0;
+      cfirstVerifyQueue = clastVerifyQueue = 0;
       apiConnectRecord = 0;
     }
+    ApiConnectRecord *apiConnectRecord;
     Uint32 cfirstVerifyQueue;
     Uint32 clastVerifyQueue;
-    Uint32 cverifyQueueCounter;
-    ApiConnectRecord *apiConnectRecord;
   };
 
   bool isEmpty(const DIVERIFY_queue&);
-  void enqueue(DIVERIFY_queue&, Ptr<ApiConnectRecord>);
-  void dequeue(DIVERIFY_queue&, Ptr<ApiConnectRecord> &);
+  void enqueue(DIVERIFY_queue&, Uint32 senderData, Uint64 gci);
+  void dequeue(DIVERIFY_queue&, ApiConnectRecord &);
 
   DIVERIFY_queue c_diverify_queue[1];
   Uint32 c_diverify_queue_cnt;

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2011-05-25 06:58:00 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2011-05-25 07:58:32 +0000
@@ -1298,6 +1298,8 @@ void Dbdih::execREAD_CONFIG_REQ(Signal* 
   ndbrequireErr(!ndb_mgm_get_int_parameter(p, CFG_DIH_API_CONNECT, 
 					   &capiConnectFileSize),
 		NDBD_EXIT_INVALID_CONFIG);
+  capiConnectFileSize++; // Increase by 1...so that srsw queue never gets full
+
   ndbrequireErr(!ndb_mgm_get_int_parameter(p, CFG_DIH_FRAG_CONNECT, 
 					   &cfragstoreFileSize),
 		NDBD_EXIT_INVALID_CONFIG);
@@ -9202,62 +9204,61 @@ void Dbdih::initialiseFragstore()
   }//for    
 }//Dbdih::initialiseFragstore()
 
+#ifndef NDB_HAVE_RMB
+#define rmb() do { } while (0)
+#endif
+
+#ifndef NDB_HAVE_WMB
+#define wmb() do { } while (0)
+#endif
+
 inline
 bool
 Dbdih::isEmpty(const DIVERIFY_queue & q)
 {
-  return q.cverifyQueueCounter == 0;
+  return q.cfirstVerifyQueue == q.clastVerifyQueue;
 }
 
 inline
 void
-Dbdih::enqueue(DIVERIFY_queue & q, Ptr<ApiConnectRecord> conRecord)
+Dbdih::enqueue(DIVERIFY_queue & q, Uint32 senderData, Uint64 gci)
 {
-  Uint32 first = q.cfirstVerifyQueue;
   Uint32 last = q.clastVerifyQueue;
-  Uint32 count = q.cverifyQueueCounter;
   ApiConnectRecord * apiConnectRecord = q.apiConnectRecord;
 
-  Ptr<ApiConnectRecord> tmp;
-  tmp.i = last;
-  if (last != RNIL)
-  {
-    tmp.i = last;
-    ptrCheckGuard(tmp, capiConnectFileSize, apiConnectRecord);
-    tmp.p->nextApi = conRecord.i;
+  apiConnectRecord[last].senderData = senderData;
+  apiConnectRecord[last].apiGci = gci;
+  wmb();
+  if (last + 1 == capiConnectFileSize)
+  {
+    q.clastVerifyQueue = 0;
   }
   else
   {
-    ndbassert(count == 0);
-    first = conRecord.i;
+    q.clastVerifyQueue = last + 1;
   }
-  q.cfirstVerifyQueue = first;
-  q.clastVerifyQueue = conRecord.i;
-  q.cverifyQueueCounter = count + 1;
+  assert(q.clastVerifyQueue != q.cfirstVerifyQueue);
 }
 
 inline
 void
-Dbdih::dequeue(DIVERIFY_queue & q, Ptr<ApiConnectRecord> & conRecord)
+Dbdih::dequeue(DIVERIFY_queue & q, ApiConnectRecord & conRecord)
 {
   Uint32 first = q.cfirstVerifyQueue;
-  Uint32 last = q.clastVerifyQueue;
-  Uint32 count = q.cverifyQueueCounter;
   ApiConnectRecord * apiConnectRecord = q.apiConnectRecord;
 
-  conRecord.i = first;
-  ptrCheckGuard(conRecord, capiConnectFileSize, apiConnectRecord);
-  Uint32 next = conRecord.p->nextApi;
-  if (first == last)
-  {
-    ndbrequire(next == RNIL);
-    ndbassert(count == 1);
-    last = RNIL;
-  }
-  ndbrequire(count > 0);
-  q.cfirstVerifyQueue = next;
-  q.clastVerifyQueue = last;
-  q.cverifyQueueCounter = count - 1;
+  rmb();
+  conRecord.senderData = apiConnectRecord[first].senderData;
+  conRecord.apiGci = apiConnectRecord[first].apiGci;
+
+  if (first + 1 == capiConnectFileSize)
+  {
+    q.cfirstVerifyQueue = 0;
+  }
+  else
+  {
+    q.cfirstVerifyQueue = first + 1;
+  }
 }
 
 /*
@@ -9295,15 +9296,8 @@ void Dbdih::execDIVERIFYREQ(Signal* sign
   // Since we are blocked we need to put this operation last in the verify
   // queue to ensure that operation starts up in the correct order.
   /*-------------------------------------------------------------------------*/
-  ApiConnectRecordPtr localApiConnectptr;
   DIVERIFY_queue & q = c_diverify_queue[0];
-
-  localApiConnectptr.i = signal->theData[0];
-  ptrCheckGuard(localApiConnectptr, capiConnectFileSize, q.apiConnectRecord);
-  localApiConnectptr.p->apiGci = m_micro_gcp.m_new_gci;
-  localApiConnectptr.p->nextApi = RNIL;
-
-  enqueue(q, localApiConnectptr);
+  enqueue(q, signal->theData[0], m_micro_gcp.m_new_gci);
   emptyverificbuffer(signal, false);
   signal->theData[3] = 1; // Indicate no immediate return
   return;
@@ -14730,12 +14724,12 @@ void Dbdih::emptyverificbuffer(Signal* s
     jam();
     return;
   }//if
-  ApiConnectRecordPtr localApiConnectptr;
+  ApiConnectRecord localApiConnect;
   if(getBlockCommit() == false){
     jam();
-    dequeue(c_diverify_queue[0], localApiConnectptr);
-    ndbrequire(localApiConnectptr.p->apiGci <= m_micro_gcp.m_current_gci);
-    signal->theData[0] = localApiConnectptr.i;
+    dequeue(c_diverify_queue[0], localApiConnect);
+    ndbrequire(localApiConnect.apiGci <= m_micro_gcp.m_current_gci);
+    signal->theData[0] = localApiConnect.senderData;
     signal->theData[1] = (Uint32)(m_micro_gcp.m_current_gci >> 32);
     signal->theData[2] = (Uint32)(m_micro_gcp.m_current_gci & 0xFFFFFFFF);
     signal->theData[3] = 0;
@@ -15464,7 +15458,8 @@ void Dbdih::initialiseRecordsLab(Signal*
       {
         refresh_watch_dog();
         ptrAss(apiConnectptr, c_diverify_queue[i].apiConnectRecord);
-        apiConnectptr.p->nextApi = RNIL;
+        apiConnectptr.p->senderData = RNIL;
+        apiConnectptr.p->apiGci = ~(Uint64)0;
       }//for
     }
     jam();
@@ -17255,10 +17250,11 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal
 	      c_nodeStartMaster.blockLcp, c_nodeStartMaster.blockGcp, c_nodeStartMaster.wait);
     for (Uint32 i = 0; i < c_diverify_queue_cnt; i++)
     {
-      infoEvent("[ %u : cfirstVerifyQueue = 0x%.8x, cverifyQueueCounter = %u ]",
+      infoEvent("[ %u : cfirstVerifyQueue = %u clastVerifyQueue = %u sz: %u]",
                 i,
                 c_diverify_queue[i].cfirstVerifyQueue,
-                c_diverify_queue[i].cverifyQueueCounter);
+                c_diverify_queue[i].clastVerifyQueue,
+                capiConnectFileSize);
     }
     infoEvent("cgcpOrderBlocked = %d",
               cgcpOrderBlocked);


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20110525075832-mzua83uv0axgjtit.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (jonas:4413) Jonas Oreland25 May