1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

MDEV-7943 - pthread_getspecific() takes 0.76% in OLTP RO

Added THD argument to select_result and all derivative classes.
This reduces number of pthread_getspecific calls from 796 to 776 per OLTP RO
transaction.
This commit is contained in:
Sergey Vojtovich
2015-04-22 13:29:56 +04:00
parent 8345bc6921
commit b22959903b
18 changed files with 149 additions and 127 deletions

View File

@@ -4074,7 +4074,7 @@ protected:
SELECT_LEX_UNIT *unit;
/* Something used only by the parser: */
public:
select_result();
select_result(THD *thd_arg): thd(thd_arg) {}
virtual ~select_result() {};
/**
Change wrapped select_result.
@@ -4203,7 +4203,8 @@ private:
class select_result_interceptor: public select_result
{
public:
select_result_interceptor() : suppress_my_ok(false)
select_result_interceptor(THD *thd_arg):
select_result(thd_arg), suppress_my_ok(false)
{
DBUG_ENTER("select_result_interceptor::select_result_interceptor");
DBUG_PRINT("enter", ("this 0x%lx", (ulong) this));
@@ -4231,7 +4232,8 @@ class select_send :public select_result {
*/
bool is_result_set_started;
public:
select_send() :is_result_set_started(FALSE) {}
select_send(THD *thd_arg):
select_result(thd_arg), is_result_set_started(FALSE) {}
bool send_result_set_metadata(List<Item> &list, uint flags);
int send_data(List<Item> &items);
bool send_eof();
@@ -4253,6 +4255,8 @@ class select_send_analyze : public select_send
bool send_result_set_metadata(List<Item> &list, uint flags) { return 0; }
bool send_eof() { return 0; }
void abort_result_set() {}
public:
select_send_analyze(THD *thd_arg): select_send(thd_arg) {}
};
@@ -4265,7 +4269,8 @@ protected:
char path[FN_REFLEN];
public:
select_to_file(sql_exchange *ex) :exchange(ex), file(-1),row_count(0L)
select_to_file(THD *thd_arg, sql_exchange *ex):
select_result_interceptor(thd_arg), exchange(ex), file(-1),row_count(0L)
{ path[0]=0; }
~select_to_file();
bool send_eof();
@@ -4307,7 +4312,7 @@ class select_export :public select_to_file {
bool fixed_row_size;
CHARSET_INFO *write_cs; // output charset
public:
select_export(sql_exchange *ex) :select_to_file(ex) {}
select_export(THD *thd_arg, sql_exchange *ex): select_to_file(thd_arg, ex) {}
~select_export();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int send_data(List<Item> &items);
@@ -4316,7 +4321,7 @@ public:
class select_dump :public select_to_file {
public:
select_dump(sql_exchange *ex) :select_to_file(ex) {}
select_dump(THD *thd_arg, sql_exchange *ex): select_to_file(thd_arg, ex) {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int send_data(List<Item> &items);
};
@@ -4330,7 +4335,7 @@ class select_insert :public select_result_interceptor {
ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not
COPY_INFO info;
bool insert_into_view;
select_insert(TABLE_LIST *table_list_par,
select_insert(THD *thd_arg, TABLE_LIST *table_list_par,
TABLE *table_par, List<Item> *fields_par,
List<Item> *update_fields, List<Item> *update_values,
enum_duplicates duplic, bool ignore);
@@ -4361,12 +4366,12 @@ class select_create: public select_insert {
bool exit_done;
public:
select_create (TABLE_LIST *table_arg,
Table_specification_st *create_info_par,
Alter_info *alter_info_arg,
List<Item> &select_fields,enum_duplicates duplic, bool ignore,
TABLE_LIST *select_tables_arg)
:select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore),
select_create(THD *thd_arg, TABLE_LIST *table_arg,
Table_specification_st *create_info_par,
Alter_info *alter_info_arg,
List<Item> &select_fields,enum_duplicates duplic, bool ignore,
TABLE_LIST *select_tables_arg):
select_insert(thd_arg, NULL, NULL, &select_fields, 0, 0, duplic, ignore),
create_table(table_arg),
create_info(create_info_par),
select_tables(select_tables_arg),
@@ -4518,7 +4523,9 @@ public:
TABLE *table;
ha_rows records;
select_union() :write_err(0), table(0), records(0) { tmp_table_param.init(); }
select_union(THD *thd_arg):
select_result_interceptor(thd_arg), write_err(0), table(0), records(0)
{ tmp_table_param.init(); }
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
/**
Do prepare() and prepare2() if they have been postponed until
@@ -4581,8 +4588,9 @@ private:
public:
/* Number of rows in the union */
ha_rows send_records;
select_union_direct(select_result *result, SELECT_LEX *last_select_lex)
:result(result), last_select_lex(last_select_lex),
select_union_direct(THD *thd_arg, select_result *result,
SELECT_LEX *last_select_lex):
select_union(thd_arg), result(result), last_select_lex(last_select_lex),
done_send_result_set_metadata(false), done_initialize_tables(false),
limit_found_rows(0)
{ send_records= 0; }
@@ -4641,7 +4649,8 @@ class select_subselect :public select_result_interceptor
protected:
Item_subselect *item;
public:
select_subselect(Item_subselect *item);
select_subselect(THD *thd_arg, Item_subselect *item_arg):
select_result_interceptor(thd_arg), item(item_arg) {}
int send_data(List<Item> &items)=0;
bool send_eof() { return 0; };
};
@@ -4650,8 +4659,8 @@ public:
class select_singlerow_subselect :public select_subselect
{
public:
select_singlerow_subselect(Item_subselect *item_arg)
:select_subselect(item_arg)
select_singlerow_subselect(THD *thd_arg, Item_subselect *item_arg):
select_subselect(thd_arg, item_arg)
{}
int send_data(List<Item> &items);
};
@@ -4696,7 +4705,8 @@ protected:
void reset();
public:
select_materialize_with_stats() { tmp_table_param.init(); }
select_materialize_with_stats(THD *thd_arg): select_union(thd_arg)
{ tmp_table_param.init(); }
bool create_result_table(THD *thd, List<Item> *column_types,
bool is_distinct, ulonglong options,
const char *alias,
@@ -4733,9 +4743,9 @@ class select_max_min_finder_subselect :public select_subselect
bool fmax;
bool is_all;
public:
select_max_min_finder_subselect(Item_subselect *item_arg, bool mx,
bool all)
:select_subselect(item_arg), cache(0), fmax(mx), is_all(all)
select_max_min_finder_subselect(THD *thd_arg, Item_subselect *item_arg,
bool mx, bool all):
select_subselect(thd_arg, item_arg), cache(0), fmax(mx), is_all(all)
{}
void cleanup();
int send_data(List<Item> &items);
@@ -4749,8 +4759,8 @@ public:
class select_exists_subselect :public select_subselect
{
public:
select_exists_subselect(Item_subselect *item_arg)
:select_subselect(item_arg){}
select_exists_subselect(THD *thd_arg, Item_subselect *item_arg):
select_subselect(thd_arg, item_arg) {}
int send_data(List<Item> &items);
};
@@ -5001,7 +5011,7 @@ class multi_delete :public select_result_interceptor
bool error_handled;
public:
multi_delete(TABLE_LIST *dt, uint num_of_tables);
multi_delete(THD *thd_arg, TABLE_LIST *dt, uint num_of_tables);
~multi_delete();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int send_data(List<Item> &items);
@@ -5048,7 +5058,7 @@ class multi_update :public select_result_interceptor
/* Need this to protect against multiple prepare() calls */
bool prepared;
public:
multi_update(TABLE_LIST *ut, List<TABLE_LIST> *leaves_list,
multi_update(THD *thd_arg, TABLE_LIST *ut, List<TABLE_LIST> *leaves_list,
List<Item> *fields, List<Item> *values,
enum_duplicates handle_duplicates, bool ignore);
~multi_update();
@@ -5106,7 +5116,8 @@ class select_dumpvar :public select_result_interceptor {
ha_rows row_count;
public:
List<my_var> var_list;
select_dumpvar() { var_list.empty(); row_count= 0;}
select_dumpvar(THD *thd_arg): select_result_interceptor(thd_arg)
{ var_list.empty(); row_count= 0; }
~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int send_data(List<Item> &items);