Commit 3e5ca03f authored by jonas@eel.(none)'s avatar jonas@eel.(none)

Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.1-ndb-new

into  eel.(none):/home/jonas/src/mysql-5.1-new
parents 4c485eb1 ae07b0a4
...@@ -619,13 +619,18 @@ struct Timer ...@@ -619,13 +619,18 @@ struct Timer
int int
main(int argc, char** argv) main(int argc, char** argv)
{ {
int sz = 3*32768; int sz = 1*32768;
int run_time = 30;
if (argc > 1) if (argc > 1)
sz = 32*atoi(argv[1]); sz = 32*atoi(argv[1]);
if (argc > 2)
run_time = atoi(argv[2]);
char buf[255]; char buf[255];
Timer timer[4]; Timer timer[4];
printf("Startar modul test av Page Manager %dMb\n", (sz >> 5)); printf("Startar modul test av Page Manager %dMb %ds\n",
(sz >> 5), run_time);
g_eventLogger.createConsoleHandler(); g_eventLogger.createConsoleHandler();
g_eventLogger.setCategory("keso"); g_eventLogger.setCategory("keso");
g_eventLogger.enable(Logger::LL_ON, Logger::LL_INFO); g_eventLogger.enable(Logger::LL_ON, Logger::LL_INFO);
...@@ -642,7 +647,7 @@ main(int argc, char** argv) ...@@ -642,7 +647,7 @@ main(int argc, char** argv)
rl.m_curr = 0; rl.m_curr = 0;
rl.m_resource_id = 0; rl.m_resource_id = 0;
mem.set_resource_limit(rl); mem.set_resource_limit(rl);
rl.m_min = 32768; rl.m_min = sz < 16384 ? sz : 16384;
rl.m_max = 0; rl.m_max = 0;
rl.m_resource_id = 1; rl.m_resource_id = 1;
mem.set_resource_limit(rl); mem.set_resource_limit(rl);
...@@ -652,13 +657,13 @@ main(int argc, char** argv) ...@@ -652,13 +657,13 @@ main(int argc, char** argv)
printf("pid: %d press enter to continue\n", getpid()); printf("pid: %d press enter to continue\n", getpid());
fgets(buf, sizeof(buf), stdin); fgets(buf, sizeof(buf), stdin);
Vector<Chunk> chunks; Vector<Chunk> chunks;
const Uint32 LOOPS = 100000000; time_t stop = time(0) + run_time;
for(Uint32 i = 0; i<LOOPS; i++){ for(Uint32 i = 0; time(0) < stop; i++){
//mem.dump(); //mem.dump();
// Case // Case
Uint32 c = (rand() % 100); Uint32 c = (rand() % 100);
if (c < 60) if (c < 50)
{ {
c = 0; c = 0;
} }
...@@ -694,7 +699,7 @@ main(int argc, char** argv) ...@@ -694,7 +699,7 @@ main(int argc, char** argv)
} }
break; break;
case 2: { // Seize(n) - fail case 2: { // Seize(n) - fail
alloc += 32000; alloc += sz;
// Fall through // Fall through
} }
case 1: { // Seize(n) (success) case 1: { // Seize(n) (success)
...@@ -750,6 +755,8 @@ main(int argc, char** argv) ...@@ -750,6 +755,8 @@ main(int argc, char** argv)
}; };
for(Uint32 i = 0; i<4; i++) for(Uint32 i = 0; i<4; i++)
timer[i].print(title[i]); timer[i].print(title[i]);
mem.dump();
} }
template class Vector<Chunk>; template class Vector<Chunk>;
......
...@@ -57,7 +57,6 @@ public: ...@@ -57,7 +57,6 @@ public:
void set_resource_limit(const Resource_limit& rl); void set_resource_limit(const Resource_limit& rl);
bool init(bool allow_alloc_less_than_requested = true); bool init(bool allow_alloc_less_than_requested = true);
void grow(Uint32 start, Uint32 cnt);
void* get_memroot() const { return (void*)m_base_page;} void* get_memroot() const { return (void*)m_base_page;}
void alloc(Uint32* ret, Uint32 *pages, Uint32 min_requested); void alloc(Uint32* ret, Uint32 *pages, Uint32 min_requested);
...@@ -68,6 +67,9 @@ public: ...@@ -68,6 +67,9 @@ public:
void* alloc_page(Uint32 type, Uint32* i); void* alloc_page(Uint32 type, Uint32* i);
void release_page(Uint32 type, Uint32 i, void * p); void release_page(Uint32 type, Uint32 i, void * p);
void* alloc_pages(Uint32 type, Uint32* i, Uint32 *cnt, Uint32 min = 1);
void release_pages(Uint32 type, Uint32 i, void*p, Uint32 cnt);
/** /**
* Compute 2log of size * Compute 2log of size
* @note size = 0 -> 0 * @note size = 0 -> 0
...@@ -76,6 +78,8 @@ public: ...@@ -76,6 +78,8 @@ public:
static Uint32 log2(Uint32 size); static Uint32 log2(Uint32 size);
private: private:
void grow(Uint32 start, Uint32 cnt);
#define XX_RL_COUNT 3 #define XX_RL_COUNT 3
/** /**
* Return pointer to free page data on page * Return pointer to free page data on page
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment