diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-04-17 14:30:15 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-05-13 10:43:14 +0400 |
commit | 4d1ccc42890029e07048772579af97072e0fa3d5 (patch) | |
tree | 38fcd49963a7fe185636a0e4045edb6e700a6dca /sql/sql_lex.cc | |
parent | c4d2c4e844717d9d5b2c0e4f0f9cfc7cc2c24fa6 (diff) | |
download | mariadb-git-4d1ccc42890029e07048772579af97072e0fa3d5.tar.gz |
MDEV-7951 - sql_alloc() takes 0.25% in OLTP RO
sql_alloc() has additional costs compared to direct mem_root allocation:
- function call: it is defined in a separate translation unit and can't be
inlined
- it needs to call pthread_getspecific() to get THD::mem_root
It is called dozens of times implicitely at least by:
- List<>::push_back()
- List<>::push_front()
- new (for Sql_alloc derived classes)
- sql_memdup()
Replaced lots of implicit sql_alloc() calls with direct mem_root allocation,
passing through THD pointer whenever it is needed.
Number of sql_alloc() calls reduced 345 -> 41 per OLTP RO transaction.
pthread_getspecific() overhead dropped 0.76 -> 0.59
sql_alloc() overhed dropped 0.25 -> 0.06
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 775f462687c..a6d2e5b6705 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1865,7 +1865,7 @@ void st_select_lex::init_query() thus push_context should be moved to a place where query initialization is checked for failure. */ - parent_lex->push_context(&context); + parent_lex->push_context(&context, parent_lex->thd->mem_root); cond_count= between_count= with_wild= 0; max_equal_elems= 0; ref_pointer_array= 0; @@ -2315,7 +2315,7 @@ bool st_select_lex::add_item_to_list(THD *thd, Item *item) { DBUG_ENTER("st_select_lex::add_item_to_list"); DBUG_PRINT("info", ("Item: 0x%lx", (long) item)); - DBUG_RETURN(item_list.push_back(item)); + DBUG_RETURN(item_list.push_back(item, thd->mem_root)); } @@ -3459,7 +3459,7 @@ bool st_select_lex::add_index_hint (THD *thd, char *str, uint length) return index_hints->push_front (new (thd->mem_root) Index_hint(current_index_hint_type, current_index_hint_clause, - str, length)); + str, length), thd->mem_root); } @@ -4135,7 +4135,7 @@ bool st_select_lex::save_leaf_tables(THD *thd) TABLE_LIST *table; while ((table= li++)) { - if (leaf_tables_exec.push_back(table)) + if (leaf_tables_exec.push_back(table, thd->mem_root)) return 1; table->tablenr_exec= table->get_tablenr(); table->map_exec= table->get_map(); |