Reduce frequent alloc of Query_Processor_Output

A new Query_Processor_Output (qpo) is allocated for every query.
Allocation is now done once per session, thus speeding up execution time
under memory profiler
pull/739/head
René Cannaò 10 years ago
parent e019047937
commit d51bed1718

@ -125,6 +125,12 @@ class Query_Processor_Output {
l_free(sizeof(Query_Processor_Output),ptr);
}
Query_Processor_Output() {
init();
}
~Query_Processor_Output() {
destroy();
}
void init() {
ptr=NULL;
size=0;
destination_hostgroup=-1;
@ -139,9 +145,10 @@ class Query_Processor_Output {
new_query=NULL;
error_msg=NULL;
}
~Query_Processor_Output() {
void destroy() {
if (error_msg) {
free(error_msg);
error_msg=NULL;
}
}
};

@ -192,7 +192,7 @@ void MySQL_Session::operator delete(void *ptr) {
MySQL_Session::MySQL_Session() {
thread_session_id=0;
pause_until=0;
qpo=NULL;
qpo=new Query_Processor_Output();
// Session_STMT_Manager=NULL;
start_time=0;
command_counters=new StatCounters(15,10,false);
@ -255,6 +255,8 @@ MySQL_Session::~MySQL_Session() {
if (admin==false && connections_handler==false && mirror==false) {
__sync_fetch_and_sub(&MyHGM->status.client_connections,1);
}
assert(qpo);
delete qpo;
// if (Session_STMT_Manager) {
// delete Session_STMT_Manager;
// }
@ -2826,10 +2828,11 @@ void MySQL_Session::RequestEnd(MySQL_Data_Stream *myds) {
}
// clean qpo
if (qpo) {
GloQPro->delete_QP_out(qpo);
qpo=NULL;
}
//if (qpo) {
// GloQPro->delete_QP_out(qpo);
// qpo=NULL;
//}
GloQPro->delete_QP_out(qpo);
// if there is an associated myds, clean its status
if (myds) {
// if there is a mysql connection, clean its status

@ -602,8 +602,11 @@ SQLite3_result * Query_Processor::get_query_digests_reset() {
Query_Processor_Output * Query_Processor::process_mysql_query(MySQL_Session *sess, void *ptr, unsigned int size, Query_Info *qi) {
Query_Processor_Output *ret=NULL;
ret=new Query_Processor_Output();
// to avoid unnecssary deallocation/allocation, we initialize qpo witout new allocation
//Query_Processor_Output *ret=NULL;
//ret=new Query_Processor_Output();
Query_Processor_Output *ret=sess->qpo;
ret->init();
SQP_par_t *qp=NULL;
if (qi) {
qp=(SQP_par_t *)&qi->QueryParserArgs;
@ -829,7 +832,8 @@ __exit_process_mysql_query:
void Query_Processor::delete_QP_out(Query_Processor_Output *o) {
//l_free(sizeof(QP_out_t),o);
if (o) {
delete o;
//delete o; // do not deallocate, but "destroy" it
o->destroy();
}
};

Loading…
Cancel
Save