Various tuning to reduce memory footprint

Monitor threads are started:
* without arena cache
* with 64KB stack

malloc_conf changed from:
xmalloc:true,lg_tcache_max:16,purge:decay
to:
xmalloc:true,lg_chunk:18,lg_tcache_max:12,purge:ratio

Conflicts:
	lib/MySQL_Monitor.cpp
pull/827/head
René Cannaò 10 years ago
parent 62480058b4
commit 0622ad77ad

1
.gitignore vendored

@ -70,6 +70,7 @@ architecture.txt
deps/jemalloc/jemalloc-3.6.0/
deps/jemalloc/jemalloc-4.1.0/
deps/jemalloc/jemalloc-4.2.1/
deps/jemalloc/jemalloc-4.3.1/
#libdaemon
deps/libdaemon/libdaemon-0.14/

@ -24,6 +24,7 @@
#define __thread_h__
#include <pthread.h>
#include "jemalloc.h"
class Thread
{
@ -31,7 +32,7 @@ class Thread
Thread();
virtual ~Thread();
int start();
int start(bool jemalloc_tcache=true);
int join();
int detach();
pthread_t self();

@ -262,6 +262,34 @@ MySQL_Monitor_State_Data::~MySQL_Monitor_State_Data() {
}
}
void * monitor_connect_pthread(void *arg) {
bool cache=false;
mallctl("thread.tcache.enabled", NULL, NULL, &cache, sizeof(bool));
GloMyMon->monitor_connect();
return NULL;
}
void * monitor_ping_pthread(void *arg) {
bool cache=false;
mallctl("thread.tcache.enabled", NULL, NULL, &cache, sizeof(bool));
GloMyMon->monitor_ping();
return NULL;
}
void * monitor_read_only_pthread(void *arg) {
bool cache=false;
// mallctl("thread.tcache.enabled", NULL, NULL, &cache, sizeof(bool));
GloMyMon->monitor_read_only();
return NULL;
}
void * monitor_replication_lag_pthread(void *arg) {
bool cache=false;
// mallctl("thread.tcache.enabled", NULL, NULL, &cache, sizeof(bool));
GloMyMon->monitor_replication_lag();
return NULL;
}
MySQL_Monitor::MySQL_Monitor() {
GloMyMon = this;
@ -1448,12 +1476,19 @@ __monitor_run:
ConsumerThread **threads= (ConsumerThread **)malloc(sizeof(ConsumerThread *)*num_threads);
for (unsigned int i=0;i<num_threads; i++) {
threads[i] = new ConsumerThread(queue, 0);
threads[i]->start();
threads[i]->start(false);
}
std::thread * monitor_connect_thread = new std::thread(&MySQL_Monitor::monitor_connect,this);
std::thread * monitor_ping_thread = new std::thread(&MySQL_Monitor::monitor_ping,this);
std::thread * monitor_read_only_thread = new std::thread(&MySQL_Monitor::monitor_read_only,this);
std::thread * monitor_replication_lag_thread = new std::thread(&MySQL_Monitor::monitor_replication_lag,this);
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize (&attr, 64*1024);
pthread_t monitor_connect_thread;
pthread_create(&monitor_connect_thread, &attr, &monitor_connect_pthread,NULL);
pthread_t monitor_ping_thread;
pthread_create(&monitor_ping_thread, &attr, &monitor_ping_pthread,NULL);
pthread_t monitor_read_only_thread;
pthread_create(&monitor_read_only_thread, &attr, &monitor_read_only_pthread,NULL);
pthread_t monitor_replication_lag_thread;
pthread_create(&monitor_replication_lag_thread, &attr, &monitor_replication_lag_pthread,NULL);
while (shutdown==false && mysql_thread___monitor_enabled==true) {
unsigned int glover;
if (GloMTH) {
@ -1492,10 +1527,10 @@ __monitor_run:
threads[i]->join();
}
free(threads);
monitor_connect_thread->join();
monitor_ping_thread->join();
monitor_read_only_thread->join();
monitor_replication_lag_thread->join();
pthread_join(monitor_connect_thread,NULL);
pthread_join(monitor_ping_thread,NULL);
pthread_join(monitor_read_only_thread,NULL);
pthread_join(monitor_replication_lag_thread,NULL);
while (shutdown==false) {
unsigned int glover;
if (GloMTH) {

@ -39,12 +39,19 @@ Thread::~Thread()
}
}
int Thread::start()
int Thread::start(bool jemalloc_tcache)
{
int result = pthread_create(&m_tid, NULL, runThread, this);
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize (&attr, 64*1024);
int result = pthread_create(&m_tid, &attr, runThread, this);
if (result == 0) {
m_running = 1;
}
if (jemalloc_tcache==false) {
bool cache=false;
mallctl("thread.tcache.enabled", NULL, NULL, &cache, sizeof(bool));
}
return result;
}

@ -129,7 +129,8 @@ static volatile int load_;
//__thread l_sfp *__thr_sfp=NULL;
const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay";
//const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay";
const char *malloc_conf = "xmalloc:true,lg_chunk:18,lg_tcache_max:12,purge:ratio";
//const char *malloc_conf = "prof_leak:true,lg_prof_sample:0,prof_final:true,xmalloc:true,lg_tcache_max:16";
int listen_fd;

Loading…
Cancel
Save