Commit 2bc6e29a authored by Sergey Vojtovich's avatar Sergey Vojtovich

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

Pass THD to Sort_and_group_tracker::report_sorting().
This reduces number of pthread_getspecific() calls from 292 to 290.
parent 360176f3
...@@ -67,7 +67,7 @@ void Filesort_tracker::print_json_members(Json_writer *writer) ...@@ -67,7 +67,7 @@ void Filesort_tracker::print_json_members(Json_writer *writer)
Tracker object to be used with filesort Tracker object to be used with filesort
*/ */
Filesort_tracker *Sort_and_group_tracker::report_sorting() Filesort_tracker *Sort_and_group_tracker::report_sorting(THD *thd)
{ {
DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS); DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS);
...@@ -79,13 +79,13 @@ Filesort_tracker *Sort_and_group_tracker::report_sorting() ...@@ -79,13 +79,13 @@ Filesort_tracker *Sort_and_group_tracker::report_sorting()
varied_executions= true; varied_executions= true;
cur_action++; cur_action++;
if (!dummy_fsort_tracker) if (!dummy_fsort_tracker)
dummy_fsort_tracker= new (current_thd->mem_root) Filesort_tracker(); dummy_fsort_tracker= new (thd->mem_root) Filesort_tracker();
return dummy_fsort_tracker; return dummy_fsort_tracker;
} }
return qep_actions_data[cur_action++].filesort_tracker; return qep_actions_data[cur_action++].filesort_tracker;
} }
Filesort_tracker *fs_tracker= new(current_thd->mem_root)Filesort_tracker(); Filesort_tracker *fs_tracker= new(thd->mem_root)Filesort_tracker();
qep_actions_data[cur_action].filesort_tracker= fs_tracker; qep_actions_data[cur_action].filesort_tracker= fs_tracker;
qep_actions[cur_action++]= EXPL_ACTION_FILESORT; qep_actions[cur_action++]= EXPL_ACTION_FILESORT;
......
...@@ -396,7 +396,7 @@ class Sort_and_group_tracker : public Sql_alloc ...@@ -396,7 +396,7 @@ class Sort_and_group_tracker : public Sql_alloc
@return @return
Tracker object to be used with filesort Tracker object to be used with filesort
*/ */
Filesort_tracker *report_sorting(); Filesort_tracker *report_sorting(THD *thd);
friend class Iterator; friend class Iterator;
/*************** Statistics retrieval interface ***************/ /*************** Statistics retrieval interface ***************/
......
...@@ -21058,7 +21058,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, ...@@ -21058,7 +21058,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
filesort_retval= filesort(thd, table, join->sortorder, length, filesort_retval= filesort(thd, table, join->sortorder, length,
select, filesort_limit, 0, select, filesort_limit, 0,
&examined_rows, &found_rows, &examined_rows, &found_rows,
join->explain->ops_tracker.report_sorting()); join->explain->ops_tracker.report_sorting(thd));
table->sort.found_records= filesort_retval; table->sort.found_records= filesort_retval;
tab->records= found_rows; // For SQL_CALC_ROWS tab->records= found_rows; // For SQL_CALC_ROWS
......
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