Improve performance due to issue #606

jemalloc configured with purge:decay_time
Temporary disabled jemalloc to test a heap profiler (heaptrack)
MySQL_ResultSet::buffer_to_PSarrayOut() calls realloc() if the buffer preallocated is too big
MySQL_Session::writeout() sends as much data as possible to the client
v1.2.0
René Cannaò 10 years ago
parent 1e0bcc572c
commit 17b7e1f609

3
.gitignore vendored

@ -101,3 +101,6 @@ deps/protobuf/protobuf-2.6.1/
test/.vagrant
.DS_Store
proxysql-tests.ini
#heaptrack
heaptrack.*

@ -1535,6 +1535,9 @@ bool MySQL_ResultSet::get_resultset(PtrSizeArray *PSarrayFinal) {
void MySQL_ResultSet::buffer_to_PSarrayOut() {
if (buffer_used==0)
return; // exit immediately if the buffer is empty
if (buffer_used < RESULTSET_BUFLEN/2) {
buffer=(unsigned char *)realloc(buffer,buffer_used);
}
PSarrayOUT->add(buffer,buffer_used);
buffer=(unsigned char *)malloc(RESULTSET_BUFLEN);
buffer_used=0;

@ -319,7 +319,29 @@ void MySQL_Session::writeout() {
//if (server_myds) server_myds->set_pollout();
if (client_myds) {
if (mirror==false) {
client_myds->write_to_net_poll();
bool runloop=false;
int retbytes=client_myds->write_to_net_poll();
if (retbytes==QUEUE_T_DEFAULT_SIZE) { // optimization to solve memory bloat
runloop=true;
}
while (runloop) {
runloop=false; // the default
client_myds->array2buffer_full();
//nfds_t nfds=1;
struct pollfd fds;
fds.fd=client_myds->fd;
fds.events=POLLOUT;
fds.revents=0;
int retpoll=poll(&fds, 1, 0);
if (retpoll>0) {
if (fds.revents==POLLOUT) {
retbytes=client_myds->write_to_net_poll();
if (retbytes==QUEUE_T_DEFAULT_SIZE) { // optimization to solve memory bloat
runloop=true;
}
}
}
}
}
}
//if (server_myds && server_myds->net_failure==false) server_myds->write_to_net_poll();

@ -56,7 +56,8 @@ LDIRS=-L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(LIBEV
MYCPPFLAGS=-std=c++11 $(IDIRS) $(OPTZ) $(DEBUG)
LDFLAGS+=
#LIBS=-rdynamic -Wl,-Bstatic -lconfig -lproxysql -ldaemon -ljemalloc -lconfig++ -lre2 -linjection -levent -lmariadbclient -lprotobuf -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl -lcrypto -lssl $(EXTRALINK)
MYLIBS=-Wl,--export-dynamic -Wl,-Bstatic -lconfig -lproxysql -ldaemon -ljemalloc -lconfig++ -lre2 -levent -lmariadbclient -Wl,-Bdynamic -lpthread -lm -lz -lrt -lcrypto -lssl $(EXTRALINK)
#MYLIBS=-Wl,--export-dynamic -Wl,-Bstatic -lconfig -lproxysql -ldaemon -ljemalloc -lconfig++ -lre2 -levent -lmariadbclient -Wl,-Bdynamic -lpthread -lm -lz -lrt -lcrypto -lssl $(EXTRALINK)
MYLIBS=-Wl,--export-dynamic -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -levent -lmariadbclient -Wl,-Bdynamic -lpthread -lm -lz -lrt -lcrypto -lssl $(EXTRALINK)
#LIBS=-rdynamic -Wl,-Bstatic -lproxysql -ljemalloc -levent $(GLIB_LIB) -Wl,-Bdynamic -ldl -lpthread -lm -lz -lrt
UNAME_S := $(shell uname -s)

@ -126,7 +126,7 @@ static volatile int load_;
//__thread l_sfp *__thr_sfp=NULL;
const char *malloc_conf = "xmalloc:true,lg_tcache_max:16";
const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay_time";
//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