1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
This commit is contained in:
Sergey Vojtovich
2015-04-17 14:30:15 +04:00
parent c4d2c4e844
commit 4d1ccc4289
20 changed files with 173 additions and 157 deletions

View File

@ -221,19 +221,22 @@ public:
}
return 1;
}
inline bool push_front(void *info)
bool push_front_impl(list_node *node)
{
list_node *node=new list_node(info,first);
if (node)
{
if (last == &first)
last= &node->next;
last= &node->next;
first=node;
elements++;
return 0;
}
return 1;
}
inline bool push_front(void *info)
{ return push_front_impl(new list_node(info, first)); }
inline bool push_front(void *info, MEM_ROOT *mem_root)
{ return push_front_impl(new (mem_root) list_node(info,first)); }
void remove(list_node **prev)
{
list_node *node=(*prev)->next;
@ -513,6 +516,8 @@ public:
inline bool push_back(T *a, MEM_ROOT *mem_root)
{ return base_list::push_back(a, mem_root); }
inline bool push_front(T *a) { return base_list::push_front(a); }
inline bool push_front(T *a, MEM_ROOT *mem_root)
{ return base_list::push_front(a, mem_root); }
inline T* head() {return (T*) base_list::head(); }
inline T** head_ref() {return (T**) base_list::head_ref(); }
inline T* pop() {return (T*) base_list::pop(); }