Commit da85ad79 authored by Monty's avatar Monty Committed by Sergei Golubchik

Optimize Sql_alloc

- Remove 'dummy_for_valgrind' overrun marker as this doesn't help much.
  The element also distorts the sizes of objects a bit, which makes it
  harder to calculate gain in object sizes when doing size optimizations.
- Replace usage of thd_get_current_thd() with _current_thd()
- Avoid one extra call indirection when using thd_get_current_thd(), which
  is used by Sql_alloc, by replacing it with _current_thd()
parent c76eabfb
......@@ -44,7 +44,6 @@ void thd_clear_errors(THD *thd);
void thd_set_thread_stack(THD *thd, char *stack_start);
void thd_lock_thread_count(THD *thd);
void thd_close_connection(THD *thd);
THD *thd_get_current_thd();
void thd_lock_data(THD *thd);
void thd_unlock_data(THD *thd);
bool thd_is_transaction_active(THD *thd);
......
......@@ -447,10 +447,10 @@ Item::Item():
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
DBUG_ASSERT(my_progname == NULL); // before main()
common_flags= IS_AUTO_GENERATED_NAME;
marker= 0;
maybe_null= with_window_func= with_field= in_rollup= with_param= 0;
fixed= 1;
null_value= 0;
join_tab_idx= MAX_TABLES;
}
......
......@@ -663,6 +663,12 @@ static std::atomic<char*> shutdown_user;
static thread_local THD *THR_THD;
/**
Get current THD object from thread local data
@retval The THD object for the thread, NULL if not connection thread
*/
MYSQL_THD _current_thd() { return THR_THD; }
void set_current_thd(THD *thd) { THR_THD= thd; }
......
......@@ -18,20 +18,18 @@
#include <my_sys.h> /* alloc_root, MEM_ROOT, TRASH */
THD *thd_get_current_thd();
/* mysql standard class memory allocator */
/* MariaDB standard class memory allocator */
class Sql_alloc
{
public:
static void *operator new(size_t size) throw ()
{
return thd_alloc(thd_get_current_thd(), size);
return thd_alloc(_current_thd(), size);
}
static void *operator new[](size_t size) throw ()
{
return thd_alloc(thd_get_current_thd(), size);
return thd_alloc(_current_thd(), size);
}
static void *operator new[](size_t size, MEM_ROOT *mem_root) throw ()
{ return alloc_root(mem_root, size); }
......@@ -42,9 +40,5 @@ class Sql_alloc
static void operator delete[](void *, MEM_ROOT *)
{ /* never called */ }
static void operator delete[](void *ptr, size_t size) { TRASH_FREE(ptr, size); }
#ifdef HAVE_valgrind
bool dummy_for_valgrind;
inline Sql_alloc() :dummy_for_valgrind(0) {}
#endif
};
#endif /* SQL_ALLOC_INCLUDED */
......@@ -325,17 +325,6 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
** Thread specific functions
****************************************************************************/
/**
Get current THD object from thread local data
@retval The THD object for the thread, NULL if not connection thread
*/
THD *thd_get_current_thd()
{
return current_thd;
}
extern "C" unsigned long long thd_query_id(const MYSQL_THD thd)
{
return((unsigned long long)thd->query_id);
......
......@@ -7812,7 +7812,7 @@ int ha_rocksdb::create(const char *const name, TABLE *const table_arg,
}
// FOREIGN KEY isn't supported yet
THD *const thd = my_core::thd_get_current_thd();
THD *const thd = _current_thd();
if (contains_foreign_key(thd)) {
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
"FOREIGN KEY for the RocksDB storage engine");
......
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