List:Commits« Previous MessageNext Message »
From:jonas Date:March 8 2007 3:41pm
Subject:bk commit into 5.1 tree (jonas:1.2456)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas 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, 2007-03-08 15:41:48+01:00, jonas@stripped +2 -0
  ndb
    change default(first) malloc on 64-bit from sbrk to malloc

  storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp@stripped, 2007-03-08 15:41:45+01:00,
jonas@stripped +72 -32
    change default malloc method on 64-bit

  storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp@stripped, 2007-03-08 15:41:45+01:00,
jonas@stripped +2 -1
    change default malloc method on 64-bit

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/51-telco

--- 1.13/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp	2007-03-08 15:41:52 +01:00
+++ 1.14/storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp	2007-03-08 15:41:52 +01:00
@@ -25,16 +25,11 @@
 extern EventLogger g_eventLogger;
 #endif
 
-#ifdef NDBD_MALLOC_METHOD
-#if NDBD_MALLOC_METHOD == sbrk
-static const char * f_method = "sbrk";
+static int f_method_idx = 0;
+#ifdef NDBD_MALLOC_METHOD_SBRK
+static const char * f_method = "SMsm";
 #else
-static const char * f_method = "malloc";
-#endif
-#elif SIZEOF_CHARP == 8
-static const char * f_method = "sbrk";
-#else
-static const char * f_method = "malloc";
+static const char * f_method = "MSms";
 #endif
 #define MAX_CHUNKS 10
 
@@ -54,28 +49,42 @@
   pages += 1;
   void * ptr = 0;
   Uint32 sz = pages;
-  if (strcmp(f_method, "sbrk") == 0)
+
+retry:
+  char method = f_method[f_method_idx];
+  switch(method){
+  case 0:
+    return false;
+  case 'S':
+  case 's':
   {
     ptr = 0;
     while (ptr == 0)
     {
       ptr = sbrk(sizeof(Alloc_page) * sz);
+      
       if (ptr == (void*)-1)
       {
+	if (method == 'S')
+	{
+	  f_method_idx++;
+	  goto retry;
+	}
+	
 	ptr = 0;
 	sz = 1 + (9 * sz) / 10;
 	if (pages >= 32 && sz < 32)
 	{
 	  sz = pages;
-	  f_method = "malloc";
-	  g_eventLogger.info("sbrk(%lld) failed, trying malloc",
-			     (Uint64)(sizeof(Alloc_page) * sz));
-	  break;
+	  f_method_idx++;
+	  goto retry;
 	}
       }
     }
+    break;
   }
-  if (strcmp(f_method, "malloc") == 0)
+  case 'M':
+  case 'm':
   {
     ptr = 0;
     while (ptr == 0)
@@ -83,15 +92,26 @@
       ptr = malloc(sizeof(Alloc_page) * sz);
       if (ptr == 0)
       {
+	if (method == 'M')
+	{
+	  f_method_idx++;
+	  goto retry;
+	}
+
 	sz = 1 + (9 * sz) / 10;
 	if (pages >= 32 && sz < 32)
 	{
-	  return false;
+	  f_method_idx++;
+	  goto retry;
 	}
       }
     }
+    break;
   }
-
+  default:
+    return false;
+  }
+  
   chunk->m_cnt = sz;
   chunk->m_ptr = (Alloc_page*)ptr;
   const UintPtr align = sizeof(Alloc_page) - 1;
@@ -362,30 +382,39 @@
     cnt--; // last page is always marked as empty
   }
   
-  if (!m_used_bitmap_pages.get(start_bmp))
+  for (Uint32 i = 0; i<m_used_bitmap_pages.size(); i++)
+    if (m_used_bitmap_pages[i] == start_bmp)
+      goto found;
+
+  if (start != (start_bmp << BPP_2LOG))
   {
-    if (start != (start_bmp << BPP_2LOG))
-    {
-      ndbout_c("ndbd_malloc_impl.cpp:%d:grow(%d, %d) %d!=%d"
-	       " - Unable to use due to bitmap pages missaligned!!",
-	       __LINE__, start, cnt, start, (start_bmp << BPP_2LOG));
-      g_eventLogger.error("ndbd_malloc_impl.cpp:%d:grow(%d, %d)"
-			  " - Unable to use due to bitmap pages missaligned!!",
-			  __LINE__, start, cnt);
-      return;
-    }
+    
+    ndbout_c("ndbd_malloc_impl.cpp:%d:grow(%d, %d) %d!=%d not using %uMb"
+	     " - Unable to use due to bitmap pages missaligned!!",
+	     __LINE__, start, cnt, start, (start_bmp << BPP_2LOG),
+	     (cnt >> (20 - 15)));
+    g_eventLogger.error("ndbd_malloc_impl.cpp:%d:grow(%d, %d) not using %uMb"
+			" - Unable to use due to bitmap pages missaligned!!",
+			__LINE__, start, cnt,
+			(cnt >> (20 - 15)));
 
+    dump();
+    return;
+  }
+  
 #ifdef UNIT_TEST
-    ndbout_c("creating bitmap page %d", start_bmp);
+  ndbout_c("creating bitmap page %d", start_bmp);
 #endif
-    
+  
+  {
     Alloc_page* bmp = m_base_page + start;
     memset(bmp, 0, sizeof(Alloc_page));
-    m_used_bitmap_pages.set(start_bmp);
     cnt--;
     start++;
   }
-
+  m_used_bitmap_pages.push_back(start_bmp);
+  
+found:
   if (cnt)
   {
     m_resource_limit[0].m_curr += cnt;
@@ -587,6 +616,15 @@
     }
     printf("EOL\n");
   }
+
+  for (Uint32 i = 0; i<XX_RL_COUNT; i++)
+  {
+    printf("ri: %d min: %d curr: %d max: %d\n",
+	   i, 
+	   m_resource_limit[i].m_min,
+	   m_resource_limit[i].m_curr,
+	   m_resource_limit[i].m_max);
+  }
 }
 
 void*
@@ -918,3 +956,5 @@
 template class Vector<Chunk>;
 
 #endif
+
+template class Vector<Uint32>;

--- 1.8/storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp	2007-03-08 15:41:52 +01:00
+++ 1.9/storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp	2007-03-08 15:41:52 +01:00
@@ -20,6 +20,7 @@
 #include <Bitmask.hpp>
 #include <assert.h>
 #include "Pool.hpp"
+#include <Vector.hpp>
 
 /**
  * 13 -> 8192 words -> 32768 bytes
@@ -82,7 +83,7 @@
    * Return pointer to free page data on page
    */
   static Free_page_data* get_free_page_data(Alloc_page*, Uint32 idx);
-  Bitmask<1> m_used_bitmap_pages;
+  Vector<Uint32> m_used_bitmap_pages;
   
   Uint32 m_buddy_lists[16];
   Resource_limit m_resource_limit[XX_RL_COUNT]; // RG_COUNT in record_types.hpp
Thread
bk commit into 5.1 tree (jonas:1.2456)jonas8 Mar