From 4d1ccc42890029e07048772579af97072e0fa3d5 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 17 Apr 2015 14:30:15 +0400 Subject: 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 --- sql/opt_range.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/opt_range.h') diff --git a/sql/opt_range.h b/sql/opt_range.h index df6dfe8c8a4..e81a536c2b6 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -69,13 +69,13 @@ class QUICK_RANGE :public Sql_alloc { uint16 dummy; /* Avoid warnings on 'flag' */ #endif QUICK_RANGE(); /* Full range */ - QUICK_RANGE(const uchar *min_key_arg, uint min_length_arg, + QUICK_RANGE(THD *thd, const uchar *min_key_arg, uint min_length_arg, key_part_map min_keypart_map_arg, const uchar *max_key_arg, uint max_length_arg, key_part_map max_keypart_map_arg, uint flag_arg) - : min_key((uchar*) sql_memdup(min_key_arg,min_length_arg+1)), - max_key((uchar*) sql_memdup(max_key_arg,max_length_arg+1)), + : min_key((uchar*) thd->memdup(min_key_arg, min_length_arg + 1)), + max_key((uchar*) thd->memdup(max_key_arg, max_length_arg + 1)), min_length((uint16) min_length_arg), max_length((uint16) max_length_arg), flag((uint16) flag_arg), -- cgit v1.2.1