diff options
author | Sergei Golubchik <serg@mariadb.org> | 2020-01-29 13:50:26 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-03-10 19:24:22 +0100 |
commit | 7c58e97bf6f80a251046c5b3e7bce826fe058bd6 (patch) | |
tree | 7d32d26b320cf83296ee0ede2ea164ad116c4de8 /storage | |
parent | 2ac3121af2767186c489054db5d4871d04b8eef4 (diff) | |
download | mariadb-git-7c58e97bf6f80a251046c5b3e7bce826fe058bd6.tar.gz |
perfschema memory related instrumentation changes
Diffstat (limited to 'storage')
93 files changed, 512 insertions, 434 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 0b352589fe3..259093d0f05 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -278,7 +278,7 @@ int archive_discover(handlerton *hton, THD* thd, TABLE_SHARE *share) if (frm_stream.frm_length == 0) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - frm_ptr= (uchar *)my_malloc(sizeof(char) * frm_stream.frm_length, + frm_ptr= (uchar *)my_malloc(PSI_INSTRUMENT_ME, frm_stream.frm_length, MYF(MY_THREAD_SPECIFIC | MY_WME)); if (!frm_ptr) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -705,7 +705,7 @@ int ha_archive::frm_copy(azio_stream *src, azio_stream *dst) return 0; } - if (!(frm_ptr= (uchar *) my_malloc(src->frm_length, + if (!(frm_ptr= (uchar *) my_malloc(PSI_INSTRUMENT_ME, src->frm_length, MYF(MY_THREAD_SPECIFIC | MY_WME)))) return HA_ERR_OUT_OF_MEM; @@ -1214,8 +1214,8 @@ bool ha_archive::fix_rec_buff(unsigned int length) if (length > record_buffer->length) { uchar *newptr; - if (!(newptr=(uchar*) my_realloc((uchar*) record_buffer->buffer, - length, + if (!(newptr=(uchar*) my_realloc(PSI_INSTRUMENT_ME, + (uchar*) record_buffer->buffer, length, MYF(MY_ALLOW_ZERO_PTR)))) DBUG_RETURN(1); record_buffer->buffer= newptr; @@ -1889,16 +1889,14 @@ archive_record_buffer *ha_archive::create_record_buffer(unsigned int length) { DBUG_ENTER("ha_archive::create_record_buffer"); archive_record_buffer *r; - if (!(r= - (archive_record_buffer*) my_malloc(sizeof(archive_record_buffer), - MYF(MY_WME)))) + if (!(r= (archive_record_buffer*) my_malloc(PSI_INSTRUMENT_ME, + sizeof(archive_record_buffer), MYF(MY_WME)))) { DBUG_RETURN(NULL); /* purecov: inspected */ } r->length= (int)length; - if (!(r->buffer= (uchar*) my_malloc(r->length, - MYF(MY_WME)))) + if (!(r->buffer= (uchar*) my_malloc(PSI_INSTRUMENT_ME, r->length, MYF(MY_WME)))) { my_free(r); DBUG_RETURN(NULL); /* purecov: inspected */ diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index c7803003398..700277f929e 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -323,9 +323,8 @@ static st_blackhole_share *get_share(const char *table_name) my_hash_search(&blackhole_open_tables, (uchar*) table_name, length))) { - if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) + - length, - MYF(MY_WME | MY_ZEROFILL)))) + if (!(share= (st_blackhole_share*) my_malloc(PSI_INSTRUMENT_ME, + sizeof(st_blackhole_share) + length, MYF(MY_WME | MY_ZEROFILL)))) goto error; share->table_name_length= length; @@ -406,7 +405,8 @@ static int blackhole_init(void *p) &blackhole_mutex, MY_MUTEX_INIT_FAST); (void) my_hash_init(&blackhole_open_tables, system_charset_info,32,0,0, (my_hash_get_key) blackhole_get_key, - (my_hash_free_key) blackhole_free_key, 0); + (my_hash_free_key) blackhole_free_key, 0, + PSI_INSTRUMENT_ME); return 0; } diff --git a/storage/cassandra/ha_cassandra.cc b/storage/cassandra/ha_cassandra.cc index 410150b088f..ac45bcaa862 100644 --- a/storage/cassandra/ha_cassandra.cc +++ b/storage/cassandra/ha_cassandra.cc @@ -243,7 +243,7 @@ static int cassandra_init_func(void *p) cassandra_hton= (handlerton *)p; mysql_mutex_init(ex_key_mutex_example, &cassandra_mutex, MY_MUTEX_INIT_FAST); (void) my_hash_init(&cassandra_open_tables,system_charset_info,32,0,0, - (my_hash_get_key) cassandra_get_key,0,0); + (my_hash_get_key) cassandra_get_key,0,0, PSI_INSTRUMENT_ME); cassandra_hton->create= cassandra_create_handler; /* @@ -297,7 +297,7 @@ static CASSANDRA_SHARE *get_share(const char *table_name, TABLE *table) length))) { if (!(share=(CASSANDRA_SHARE *) - my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), + my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), PSI_INSTRUMENT_ME, &share, sizeof(*share), &tmp_name, length+1, NullS))) @@ -865,7 +865,7 @@ static void alloc_strings_memroot(MEM_ROOT *mem_root) The mem_root used to allocate UUID (of length 36 + \0) so make appropriate allocated size */ - init_alloc_root(mem_root, "cassandra", + init_alloc_root(PSI_INSTRUMENT_ME, mem_root, (36 + 1 + ALIGN_SIZE(sizeof(USED_MEM))) * 10 + ALLOC_ROOT_MIN_BLOCK_SIZE, (36 + 1 + ALIGN_SIZE(sizeof(USED_MEM))) * 10 + @@ -1446,7 +1446,7 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields) size_t memsize= sizeof(ColumnDataConverter*) * n_fields + (sizeof(LEX_STRING) + sizeof(CASSANDRA_TYPE_DEF))* (dyncol_set ? max_non_default_fields : 0); - if (!(field_converters= (ColumnDataConverter**)my_malloc(memsize, MYF(0)))) + if (!(field_converters= (ColumnDataConverter**)my_malloc(PSI_INSTRUMENT_ME, memsize, MYF(0)))) DBUG_RETURN(true); bzero(field_converters, memsize); n_field_converters= n_fields; @@ -1458,12 +1458,12 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields) special_type_field_names= ((LEX_STRING*)(special_type_field_converters + max_non_default_fields)); - if (my_init_dynamic_array(&dynamic_values, + if (my_init_dynamic_array(&dynamic_values, PSI_INSTRUMENT_ME, sizeof(DYNAMIC_COLUMN_VALUE), DYNCOL_USUAL, DYNCOL_DELTA, MYF(0))) DBUG_RETURN(true); else - if (my_init_dynamic_array(&dynamic_names, + if (my_init_dynamic_array(&dynamic_names, PSI_INSTRUMENT_ME, sizeof(LEX_STRING), DYNCOL_USUAL, DYNCOL_DELTA,MYF(0))) { diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index e07270aff8a..abb865cc61f 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -88,8 +88,8 @@ static MYSQL_RES *connect_use_result(MYSQL *mysql) DBUG_RETURN(NULL); } // endif status - if (!(result = (MYSQL_RES*) my_malloc(sizeof(*result) + - sizeof(ulong) * mysql->field_count, + if (!(result = (MYSQL_RES*) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(*result) + sizeof(ulong) * mysql->field_count, MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(NULL); @@ -97,8 +97,8 @@ static MYSQL_RES *connect_use_result(MYSQL *mysql) result->methods = mysql->methods; /* Ptrs: to one row */ - if (!(result->row = (MYSQL_ROW)my_malloc(sizeof(result->row[0]) * - (mysql->field_count+1), MYF(MY_WME)))) { + if (!(result->row = (MYSQL_ROW)my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(result->row[0]) * (mysql->field_count+1), MYF(MY_WME)))) { my_free(result); DBUG_RETURN(NULL); } // endif row diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index ac5a0eeb850..7fbf3afd830 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -112,6 +112,11 @@ static uchar* tina_get_key(TINA_SHARE *share, size_t *length, return (uchar*) share->table_name; } +static PSI_memory_key csv_key_memory_tina_share; +static PSI_memory_key csv_key_memory_blobroot; +static PSI_memory_key csv_key_memory_tina_set; +static PSI_memory_key csv_key_memory_row; + #ifdef HAVE_PSI_INTERFACE static PSI_mutex_key csv_key_mutex_tina, csv_key_mutex_TINA_SHARE_mutex; @@ -132,6 +137,15 @@ static PSI_file_info all_tina_files[]= { &csv_key_file_update, "update", 0} }; +static PSI_memory_info all_tina_memory[]= +{ + { &csv_key_memory_tina_share, "TINA_SHARE", PSI_FLAG_GLOBAL}, + { &csv_key_memory_blobroot, "blobroot", 0}, + { &csv_key_memory_tina_set, "tina_set", 0}, + { &csv_key_memory_row, "row", 0}, + { &csv_key_memory_Transparent_file, "Transparent_file", 0} +}; + static void init_tina_psi_keys(void) { const char* category= "csv"; @@ -142,6 +156,9 @@ static void init_tina_psi_keys(void) count= array_elements(all_tina_files); mysql_file_register(category, all_tina_files, count); + + count= array_elements(all_tina_memory); + mysql_memory_register(category, all_tina_memory, count); } #endif /* HAVE_PSI_INTERFACE */ @@ -166,8 +183,9 @@ static int tina_init_func(void *p) tina_hton= (handlerton *)p; mysql_mutex_init(csv_key_mutex_tina, &tina_mutex, MY_MUTEX_INIT_FAST); - (void) my_hash_init(&tina_open_tables,system_charset_info,32,0,0, - (my_hash_get_key) tina_get_key,0,0); + (void) my_hash_init(&tina_open_tables, system_charset_info, 32, 0, 0, + (my_hash_get_key) tina_get_key, 0, 0, + csv_key_memory_tina_share); tina_hton->db_type= DB_TYPE_CSV_DB; tina_hton->create= tina_create_handler; tina_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES | @@ -204,14 +222,11 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) If share is not present in the hash, create a new share and initialize its members. */ - if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables, - (uchar*) table_name, - length))) + if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables, (uchar*) + table_name, length))) { - if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &share, sizeof(*share), - &tmp_name, length+1, - NullS)) + if (!my_multi_malloc(csv_key_memory_tina_share, MYF(MY_WME | MY_ZEROFILL), + &share, sizeof(*share), &tmp_name, length+1, NullS)) { mysql_mutex_unlock(&tina_mutex); return NULL; @@ -513,7 +528,8 @@ ha_tina::ha_tina(handlerton *hton, TABLE_SHARE *table_arg) buffer.set((char*)byte_buffer, IO_SIZE, &my_charset_bin); chain= chain_buffer; file_buff= new Transparent_file(); - init_alloc_root(&blobroot, "ha_tina", BLOB_MEMROOT_ALLOC_SIZE, 0, MYF(0)); + init_alloc_root(csv_key_memory_blobroot, &blobroot, BLOB_MEMROOT_ALLOC_SIZE, + 0, MYF(0)); } @@ -627,14 +643,15 @@ int ha_tina::chain_append() chain_size += DEFAULT_CHAIN_LENGTH; if (chain_alloced) { - /* Must cast since my_malloc unlike malloc doesn't have a void ptr */ - if ((chain= (tina_set *) my_realloc((uchar*)chain, - chain_size, MYF(MY_WME))) == NULL) + if ((chain= (tina_set *) my_realloc(csv_key_memory_tina_set, + (uchar*)chain, chain_size, + MYF(MY_WME))) == NULL) return -1; } else { - tina_set *ptr= (tina_set *) my_malloc(chain_size * sizeof(tina_set), + tina_set *ptr= (tina_set *) my_malloc(csv_key_memory_tina_set, + chain_size * sizeof(tina_set), MYF(MY_WME)); memcpy(ptr, chain, DEFAULT_CHAIN_LENGTH * sizeof(tina_set)); chain= ptr; @@ -975,7 +992,8 @@ int ha_tina::open(const char *name, int mode, uint open_options) */ thr_lock_data_init(&share->lock, &lock, (void*) this); ref_length= sizeof(my_off_t); - init_alloc_root(&blobroot, "ha_tina", BLOB_MEMROOT_ALLOC_SIZE, 0, MYF(0)); + init_alloc_root(csv_key_memory_blobroot, &blobroot, BLOB_MEMROOT_ALLOC_SIZE, + 0, MYF(0)); share->lock.get_status= tina_get_status; share->lock.update_status= tina_update_status; @@ -1528,7 +1546,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) if (init_data_file()) DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR); - if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)))) + if (!(buf= (uchar*) my_malloc(csv_key_memory_row, table->s->reclength, + MYF(MY_WME)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* Local_saved_data_file_length is initialized during the lock phase. @@ -1742,7 +1761,8 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt) if (init_data_file()) DBUG_RETURN(HA_ERR_CRASHED); - if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)))) + if (!(buf= (uchar*) my_malloc(csv_key_memory_row, table->s->reclength, + MYF(MY_WME)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc index 47d63f2caaf..443e61d08d8 100644 --- a/storage/csv/transparent_file.cc +++ b/storage/csv/transparent_file.cc @@ -23,9 +23,12 @@ #include "transparent_file.h" #include "my_sys.h" // MY_WME, MY_ALLOW_ZERO_PTR, MY_SEEK_SET +PSI_memory_key csv_key_memory_Transparent_file; + Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE) { - buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME)); + buff= (uchar *) my_malloc(csv_key_memory_Transparent_file, + buff_size*sizeof(uchar), MYF(MY_WME)); } Transparent_file::~Transparent_file() diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h index 024fc0e3a38..545643d0f17 100644 --- a/storage/csv/transparent_file.h +++ b/storage/csv/transparent_file.h @@ -18,6 +18,7 @@ #include <sys/stat.h> #include <my_dir.h> +extern PSI_memory_key csv_key_memory_Transparent_file; class Transparent_file { diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 2021e03bc62..8dc6c9e0698 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -497,7 +497,7 @@ int federated_db_init(void *p) &federated_mutex, MY_MUTEX_INIT_FAST)) goto error; if (!my_hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0, - (my_hash_get_key) federated_get_key, 0, 0)) + (my_hash_get_key) federated_get_key, 0, 0, PSI_INSTRUMENT_ME)) { DBUG_RETURN(FALSE); } @@ -1516,7 +1516,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) */ query.length(0); - init_alloc_root(&mem_root, "federated_share", 256, 0, MYF(0)); + init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 256, 0, MYF(0)); mysql_mutex_lock(&federated_mutex); @@ -1642,7 +1642,7 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked) ref_length= sizeof(MYSQL_RES *) + sizeof(MYSQL_ROW_OFFSET); DBUG_PRINT("info", ("ref_length: %u", ref_length)); - my_init_dynamic_array(&results, sizeof(MYSQL_RES *), 4, 4, MYF(0)); + my_init_dynamic_array(&results, PSI_INSTRUMENT_ME, sizeof(MYSQL_RES *), 4, 4, MYF(0)); reset(); DBUG_RETURN(0); diff --git a/storage/federatedx/federatedx_io_mysql.cc b/storage/federatedx/federatedx_io_mysql.cc index cc4d8ca7c70..4d4e8b11165 100644 --- a/storage/federatedx/federatedx_io_mysql.cc +++ b/storage/federatedx/federatedx_io_mysql.cc @@ -140,7 +140,7 @@ federatedx_io_mysql::federatedx_io_mysql(FEDERATEDX_SERVER *aserver) bzero(&mysql, sizeof(MYSQL)); bzero(&savepoints, sizeof(DYNAMIC_ARRAY)); - my_init_dynamic_array(&savepoints, sizeof(SAVEPT), 16, 16, MYF(0)); + my_init_dynamic_array(&savepoints, PSI_INSTRUMENT_ME, sizeof(SAVEPT), 16, 16, MYF(0)); DBUG_VOID_RETURN; } diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index eca580310ee..b042fa720dc 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -446,9 +446,9 @@ int federatedx_db_init(void *p) &federatedx_mutex, MY_MUTEX_INIT_FAST)) goto error; if (!my_hash_init(&federatedx_open_tables, &my_charset_bin, 32, 0, 0, - (my_hash_get_key) federatedx_share_get_key, 0, 0) && + (my_hash_get_key) federatedx_share_get_key, 0, 0, PSI_INSTRUMENT_ME) && !my_hash_init(&federatedx_open_servers, &my_charset_bin, 32, 0, 0, - (my_hash_get_key) federatedx_server_get_key, 0, 0)) + (my_hash_get_key) federatedx_server_get_key, 0, 0, PSI_INSTRUMENT_ME)) { DBUG_RETURN(FALSE); } @@ -1540,7 +1540,7 @@ static FEDERATEDX_SERVER *get_server(FEDERATEDX_SHARE *share, TABLE *table) mysql_mutex_assert_owner(&federatedx_mutex); - init_alloc_root(&mem_root, "federated", 4096, 4096, MYF(0)); + init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 4096, 4096, MYF(0)); fill_server(&mem_root, &tmp_server, share, table ? table->s->table_charset : 0); @@ -1598,7 +1598,7 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table) query.length(0); bzero(&tmp_share, sizeof(tmp_share)); - init_alloc_root(&mem_root, "federated", 256, 0, MYF(0)); + init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 256, 0, MYF(0)); mysql_mutex_lock(&federatedx_mutex); @@ -1802,7 +1802,7 @@ int ha_federatedx::open(const char *name, int mode, uint test_if_locked) DBUG_PRINT("info", ("ref_length: %u", ref_length)); - my_init_dynamic_array(&results, sizeof(FEDERATEDX_IO_RESULT*), 4, 4, MYF(0)); + my_init_dynamic_array(&results, PSI_INSTRUMENT_ME, sizeof(FEDERATEDX_IO_RESULT*), 4, 4, MYF(0)); reset(); diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index e0e25442d71..ccfd6c69956 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -619,7 +619,8 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table, for (key= parts= 0; key < keys; key++) parts+= table_arg->key_info[key].user_defined_key_parts; - if (!(keydef= (HP_KEYDEF*) my_malloc(keys * sizeof(HP_KEYDEF) + + if (!(keydef= (HP_KEYDEF*) my_malloc(hp_key_memory_HP_KEYDEF, + keys * sizeof(HP_KEYDEF) + parts * sizeof(HA_KEYSEG), MYF(MY_WME | MY_THREAD_SPECIFIC)))) return my_errno; diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h index b3ceb617bd4..6136a90f0aa 100644 --- a/storage/heap/heapdef.h +++ b/storage/heap/heapdef.h @@ -103,8 +103,12 @@ extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, extern mysql_mutex_t THR_LOCK_heap; +extern PSI_memory_key hp_key_memory_HP_SHARE; +extern PSI_memory_key hp_key_memory_HP_INFO; +extern PSI_memory_key hp_key_memory_HP_PTRS; +extern PSI_memory_key hp_key_memory_HP_KEYDEF; + #ifdef HAVE_PSI_INTERFACE -extern PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock; void init_heap_psi_keys(); #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c index 395637db351..324efc8b4af 100644 --- a/storage/heap/hp_block.c +++ b/storage/heap/hp_block.c @@ -78,7 +78,7 @@ int hp_get_new_block(HP_SHARE *info, HP_BLOCK *block, size_t *alloc_length) */ *alloc_length= (sizeof(HP_PTRS) * ((i == block->levels) ? i : i - 1) + (ulonglong)block->records_in_block * block->recbuffer); - if (!(root=(HP_PTRS*) my_malloc(*alloc_length, + if (!(root=(HP_PTRS*) my_malloc(hp_key_memory_HP_PTRS, *alloc_length, MYF(MY_WME | (info->internal ? MY_THREAD_SPECIFIC : 0))))) diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index 8bd653f1b84..935c6f8d0fd 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -159,7 +159,8 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, keyinfo->get_key_length= hp_rb_key_length; } } - if (!(share= (HP_SHARE*) my_malloc((uint) sizeof(HP_SHARE)+ + if (!(share= (HP_SHARE*) my_malloc(hp_key_memory_HP_SHARE, + sizeof(HP_SHARE)+ keys*sizeof(HP_KEYDEF)+ key_segs*sizeof(HA_KEYSEG), MYF(MY_ZEROFILL | @@ -222,7 +223,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, share->create_time= (long) time((time_t*) 0); share->internal= create_info->internal_table; /* Must be allocated separately for rename to work */ - if (!(share->name= my_strdup(name,MYF(0)))) + if (!(share->name= my_strdup(hp_key_memory_HP_SHARE, name, MYF(0)))) { my_free(share); goto err; @@ -231,8 +232,6 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, if (!create_info->internal_table) { thr_lock_init(&share->lock); - mysql_mutex_init(hp_key_mutex_HP_SHARE_intern_lock, - &share->intern_lock, MY_MUTEX_INIT_FAST); share->open_list.data= (void*) share; heap_share_list= list_add(heap_share_list,&share->open_list); } @@ -361,7 +360,6 @@ void hp_free(HP_SHARE *share) { heap_share_list= list_delete(heap_share_list, &share->open_list); thr_lock_delete(&share->lock); - mysql_mutex_destroy(&share->intern_lock); } hp_clear(share); /* Remove blocks from memory */ my_free(share->name); diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c index 65186d77e4f..272c4a3af23 100644 --- a/storage/heap/hp_open.c +++ b/storage/heap/hp_open.c @@ -30,8 +30,8 @@ HP_INFO *heap_open_from_share(HP_SHARE *share, int mode) HP_INFO *info; DBUG_ENTER("heap_open_from_share"); - if (!(info= (HP_INFO*) my_malloc(sizeof(HP_INFO) + - 2 * share->max_key_length, + if (!(info= (HP_INFO*) my_malloc(hp_key_memory_HP_INFO, + sizeof(HP_INFO) + 2 * share->max_key_length, MYF(MY_ZEROFILL + (share->internal ? MY_THREAD_SPECIFIC : 0))))) diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c index 34e82bbc531..7343644b5d9 100644 --- a/storage/heap/hp_rename.c +++ b/storage/heap/hp_rename.c @@ -28,7 +28,8 @@ int heap_rename(const char *old_name, const char *new_name) mysql_mutex_lock(&THR_LOCK_heap); if ((info = hp_find_named_heap(old_name))) { - if (!(name_buff=(char*) my_strdup(new_name,MYF(MY_WME)))) + if (!(name_buff=(char*) my_strdup(hp_key_memory_HP_SHARE, + new_name, MYF(MY_WME)))) { mysql_mutex_unlock(&THR_LOCK_heap); DBUG_RETURN(my_errno); diff --git a/storage/heap/hp_static.c b/storage/heap/hp_static.c index 9191e23b399..9a4410eead9 100644 --- a/storage/heap/hp_static.c +++ b/storage/heap/hp_static.c @@ -24,16 +24,19 @@ LIST *heap_open_list=0,*heap_share_list=0; +PSI_memory_key hp_key_memory_HP_SHARE; +PSI_memory_key hp_key_memory_HP_INFO; +PSI_memory_key hp_key_memory_HP_PTRS; +PSI_memory_key hp_key_memory_HP_KEYDEF; + #ifdef HAVE_PSI_INTERFACE -PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock; -static PSI_mutex_info all_heap_mutexes[]= +static PSI_memory_info all_heap_memory[]= { - { & hp_key_mutex_HP_SHARE_intern_lock, "HP_SHARE::intern_lock", 0} - /* - Note: - THR_LOCK_heap is part of mysys, not storage/heap. - */ + { & hp_key_memory_HP_SHARE, "HP_SHARE", 0}, + { & hp_key_memory_HP_INFO, "HP_INFO", 0}, + { & hp_key_memory_HP_PTRS, "HP_PTRS", 0}, + { & hp_key_memory_HP_KEYDEF, "HP_KEYDEF", 0} }; void init_heap_psi_keys() @@ -44,8 +47,8 @@ void init_heap_psi_keys() if (PSI_server == NULL) return; - count= array_elements(all_heap_mutexes); - PSI_server->register_mutex(category, all_heap_mutexes, count); + count= array_elements(all_heap_memory); + mysql_memory_register(category, all_heap_memory, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index be7de608d2b..c2094b23d3a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4554,7 +4554,7 @@ innobase_checkpoint_request( /* Do the allocation outside of lock to reduce contention. The normal case is that not everything is flushed, so we will need to enqueue. */ entry = static_cast<struct pending_checkpoint *> - (my_malloc(sizeof(*entry), MYF(MY_WME))); + (my_malloc(PSI_INSTRUMENT_ME, sizeof(*entry), MYF(MY_WME))); if (!entry) { sql_print_error("Failed to allocate %u bytes." " Commit checkpoint will be skipped.", @@ -8540,7 +8540,7 @@ ha_innobase::update_row( + MAX_REF_PARTS * 3; m_upd_buf = reinterpret_cast<uchar*>( - my_malloc(//PSI_INSTRUMENT_ME, + my_malloc(PSI_INSTRUMENT_ME, m_upd_buf_size, MYF(MY_WME))); @@ -9681,7 +9681,7 @@ ha_innobase::ft_init_ext( /* Allocate FTS handler, and instantiate it before return */ fts_hdl = reinterpret_cast<NEW_FT_INFO*>( - my_malloc(/*PSI_INSTRUMENT_ME,*/ sizeof(NEW_FT_INFO), MYF(0))); + my_malloc(PSI_INSTRUMENT_ME, sizeof(NEW_FT_INFO), MYF(0))); fts_hdl->please = const_cast<_ft_vft*>(&ft_vft_result); fts_hdl->could_you = const_cast<_ft_vft_ext*>(&ft_vft_ext_result); @@ -10964,7 +10964,7 @@ create_index( ind_type |= DICT_UNIQUE; } - field_lengths = (ulint*) my_malloc(//PSI_INSTRUMENT_ME, + field_lengths = (ulint*) my_malloc(PSI_INSTRUMENT_ME, key->user_defined_key_parts * sizeof * field_lengths, MYF(MY_FAE)); @@ -13645,7 +13645,7 @@ innobase_drop_database( } ptr++; - namebuf = (char*) my_malloc(/*PSI_INSTRUMENT_ME,*/ (uint) len + 2, MYF(0)); + namebuf = (char*) my_malloc(PSI_INSTRUMENT_ME, (uint) len + 2, MYF(0)); memcpy(namebuf, ptr, len); namebuf[len] = '/'; @@ -15249,7 +15249,7 @@ ha_innobase::update_table_comment( flen = 64000 - 3 - length; } /* allocate buffer for the full string */ - str = (char*) my_malloc(length + flen + 3, MYF(0)); + str = (char*) my_malloc(PSI_INSTRUMENT_ME, length + flen + 3, MYF(0)); if (str) { char* pos = str + length; if (length) { @@ -15294,14 +15294,8 @@ ha_innobase::get_foreign_key_create_info(void) m_prebuilt->trx->op_info = ""; /* Allocate buffer for the string */ - char* fk_str = (char*) my_malloc(str.length() + 1, MYF(0)); - - /* JAN: TODO: MySQL 5.7 - fk_str = reinterpret_cast<char*>( + char *fk_str = reinterpret_cast<char*>( my_malloc(PSI_INSTRUMENT_ME, str.length() + 1, MYF(0))); - */ - - if (fk_str) { memcpy(fk_str, str.c_str(), str.length()); @@ -16174,7 +16168,7 @@ innodb_show_status( /* allocate buffer for the string, and read the contents of the temporary file */ - if (!(str = (char*) my_malloc(//PSI_INSTRUMENT_ME, + if (!(str = (char*) my_malloc(PSI_INSTRUMENT_ME, usable_len + 1, MYF(0)))) { mutex_exit(&srv_monitor_file_mutex); DBUG_RETURN(1); @@ -18105,7 +18099,7 @@ innodb_monitor_validate( by InnoDB, so we can access it in another callback function innodb_monitor_update() and free it appropriately */ if (name) { - monitor_name = my_strdup(//PSI_INSTRUMENT_ME, + monitor_name = my_strdup(PSI_INSTRUMENT_ME, name, MYF(0)); } else { return(1); @@ -21635,7 +21629,7 @@ ib_push_warning( char *buf; va_start(args, format); - buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME)); + buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME)); vsprintf(buf,format, args); push_warning_printf( @@ -21666,7 +21660,7 @@ ib_push_warning( if (thd) { va_start(args, format); - buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME)); + buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME)); vsprintf(buf,format, args); push_warning_printf( @@ -21695,7 +21689,7 @@ ib_foreign_warn(trx_t* trx, /*!< in: trx */ char* buf; static FILE* ef = dict_foreign_err_file; static const size_t MAX_BUF_SIZE = 4 * 1024; - buf = (char*)my_malloc(MAX_BUF_SIZE, MYF(MY_WME)); + buf = (char*)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME)); if (!buf) { return; } diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index fc152099610..f026ab5dfa5 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -4620,12 +4620,8 @@ static int i_s_innodb_fill_buffer_lru(THD *thd, TABLE_LIST *tables, Item *) lru_len = UT_LIST_GET_LEN(buf_pool->LRU); /* Print error message if malloc fail */ - info_buffer = (buf_page_info_t*) my_malloc( - lru_len * sizeof *info_buffer, MYF(MY_WME)); - /* JAN: TODO: MySQL 5.7 PSI info_buffer = (buf_page_info_t*) my_malloc(PSI_INSTRUMENT_ME, lru_len * sizeof *info_buffer, MYF(MY_WME)); - */ if (!info_buffer) { status = 1; diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic index a1bbf719b7d..4791c801424 100644 --- a/storage/innobase/include/sync0rw.ic +++ b/storage/innobase/include/sync0rw.ic @@ -541,8 +541,6 @@ pfs_rw_lock_x_lock_func( /* Record the acquisition of a read-write lock in exclusive mode in performance schema */ -/* MySQL 5.7 New PSI */ -#define PSI_RWLOCK_EXCLUSIVELOCK PSI_RWLOCK_WRITELOCK locker = PSI_RWLOCK_CALL(start_rwlock_wrwait)( &state, lock->pfs_psi, PSI_RWLOCK_EXCLUSIVELOCK, @@ -582,7 +580,6 @@ pfs_rw_lock_x_lock_func_nowait( /* Record the acquisition of a read-write trylock in exclusive mode in performance schema */ -#define PSI_RWLOCK_TRYEXCLUSIVELOCK PSI_RWLOCK_TRYWRITELOCK locker = PSI_RWLOCK_CALL(start_rwlock_wrwait)( &state, lock->pfs_psi, PSI_RWLOCK_TRYEXCLUSIVELOCK, file_name, static_cast<uint>(line)); @@ -636,7 +633,6 @@ pfs_rw_lock_s_lock_func( PSI_rwlock_locker* locker; PSI_rwlock_locker_state state; -#define PSI_RWLOCK_SHAREDLOCK PSI_RWLOCK_READLOCK /* Instrumented to inform we are aquiring a shared rwlock */ locker = PSI_RWLOCK_CALL(start_rwlock_rdwait)( &state, lock->pfs_psi, PSI_RWLOCK_SHAREDLOCK, @@ -671,7 +667,6 @@ pfs_rw_lock_sx_lock_func( PSI_rwlock_locker* locker; PSI_rwlock_locker_state state; -#define PSI_RWLOCK_SHAREDEXCLUSIVELOCK PSI_RWLOCK_WRITELOCK /* Instrumented to inform we are aquiring a shared rwlock */ locker = PSI_RWLOCK_CALL(start_rwlock_wrwait)( &state, lock->pfs_psi, PSI_RWLOCK_SHAREDEXCLUSIVELOCK, @@ -708,7 +703,6 @@ pfs_rw_lock_s_lock_low( PSI_rwlock_locker* locker; PSI_rwlock_locker_state state; -#define PSI_RWLOCK_TRYSHAREDLOCK PSI_RWLOCK_TRYREADLOCK /* Instrumented to inform we are aquiring a shared rwlock */ locker = PSI_RWLOCK_CALL(start_rwlock_rdwait)( &state, lock->pfs_psi, PSI_RWLOCK_TRYSHAREDLOCK, @@ -748,7 +742,6 @@ pfs_rw_lock_sx_lock_low( PSI_rwlock_locker* locker; PSI_rwlock_locker_state state; -#define PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK PSI_RWLOCK_TRYWRITELOCK /* Instrumented to inform we are aquiring a shared exclusive rwlock */ locker = PSI_RWLOCK_CALL(start_rwlock_rdwait)( diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index a190b872549..0a2bfdd2530 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -232,38 +232,19 @@ struct ut_new_pfx_t { #endif }; -static inline void ut_allocate_trace_dontdump(void *ptr, size_t bytes, - bool -#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DONTDUMP) - dontdump -#endif - , ut_new_pfx_t* pfx, - const char* -#ifdef UNIV_PFS_MEMORY - file -#endif - - ) +#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DODUMP) +static inline void ut_dontdump(void *ptr, size_t m_size, bool dontdump) { ut_a(ptr != NULL); -#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DONTDUMP) - if (dontdump && madvise(ptr, bytes, MADV_DONTDUMP)) { + if (dontdump && madvise(ptr, m_size, MADV_DONTDUMP)) { ib::warn() << "Failed to set memory to " DONTDUMP_STR ": " << strerror(errno) << " ptr " << ptr - << " size " << bytes; - } -#endif - if (pfx != NULL) { -#ifdef UNIV_PFS_MEMORY - allocate_trace(bytes, file, pfx); -#endif /* UNIV_PFS_MEMORY */ - pfx->m_size = bytes; + << " size " << m_size; } } -#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DODUMP) static inline void ut_dodump(void* ptr, size_t m_size) { if (ptr && madvise(ptr, m_size, MADV_DODUMP)) { @@ -274,6 +255,7 @@ static inline void ut_dodump(void* ptr, size_t m_size) } } #else +static inline void ut_dontdump(void *, size_t, bool) {} static inline void ut_dodump(void*, size_t) {} #endif @@ -310,10 +292,14 @@ public: other #endif ) + { #ifdef UNIV_PFS_MEMORY - : m_key(other.m_key) + const PSI_memory_key other_key = other.get_mem_key(NULL); + + m_key = (other_key != mem_key_std) + ? other_key + : PSI_NOT_INSTRUMENTED; #endif /* UNIV_PFS_MEMORY */ - { } /** Return the maximum number of objects that can be allocated by @@ -422,7 +408,7 @@ public: /** Free a memory allocated by allocate() and trace the deallocation. @param[in,out] ptr pointer to memory to free */ - void deallocate(pointer ptr, size_type) + void deallocate(pointer ptr, size_type n_elements = 0) { #ifdef UNIV_PFS_MEMORY if (ptr == NULL) { @@ -645,7 +631,14 @@ public: return NULL; } - ut_allocate_trace_dontdump(ptr, n_bytes, dontdump, pfx, NULL); + ut_dontdump(ptr, n_bytes, dontdump); + + if (pfx != NULL) { +#ifdef UNIV_PFS_MEMORY + allocate_trace(n_bytes, NULL, pfx); +#endif /* UNIV_PFS_MEMORY */ + pfx->m_size = n_bytes; + } return(ptr); } @@ -924,9 +917,9 @@ ut_delete_array( ut_allocator<byte>(key).allocate( \ n_bytes, NULL, __FILE__, false, false)) -#define ut_malloc_dontdump(n_bytes) static_cast<void*>( \ - ut_allocator<byte>(PSI_NOT_INSTRUMENTED).allocate_large( \ - n_bytes, true)) +#define ut_malloc_dontdump(n_bytes, key) static_cast<void*>( \ + ut_allocator<byte>(key).allocate_large( \ + n_bytes, NULL, true)) #define ut_zalloc(n_bytes, key) static_cast<void*>( \ ut_allocator<byte>(key).allocate( \ @@ -951,9 +944,8 @@ ut_delete_array( #define ut_free(ptr) ut_allocator<byte>(PSI_NOT_INSTRUMENTED).deallocate( \ reinterpret_cast<byte*>(ptr)) -#define ut_free_dodump(ptr, size) static_cast<void*>( \ - ut_allocator<byte>(PSI_NOT_INSTRUMENTED).deallocate_large( \ - ptr, NULL, size, true)) +#define ut_free_dodump(ptr, size) ut_allocator<byte>(PSI_NOT_INSTRUMENTED).deallocate_large_dodump( \ + reinterpret_cast<byte*>(ptr), NULL, size) #else /* UNIV_PFS_MEMORY */ @@ -977,11 +969,11 @@ ut_delete_array( #define ut_malloc_nokey(n_bytes) ::malloc(n_bytes) -static inline void *ut_malloc_dontdump(size_t n_bytes) +static inline void *ut_malloc_dontdump(size_t n_bytes, ...) { void *ptr = os_mem_alloc_large(&n_bytes); - ut_allocate_trace_dontdump(ptr, n_bytes, true, NULL, NULL); + ut_dontdump(ptr, n_bytes, true); return ptr; } diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index de6e51bd2ea..7e291c8d8df 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -127,7 +127,7 @@ void log_buffer_extend(ulong len) { const size_t new_buf_size = ut_calc_align(len, srv_page_size); byte* new_buf = static_cast<byte*>( - ut_malloc_dontdump(new_buf_size * 2)); + ut_malloc_dontdump(new_buf_size * 2, PSI_INSTRUMENT_ME)); TRASH_ALLOC(new_buf, new_buf_size * 2); log_mutex_enter(); @@ -508,7 +508,7 @@ void log_t::create() ut_ad(srv_log_buffer_size >= 16 * OS_FILE_LOG_BLOCK_SIZE); ut_ad(srv_log_buffer_size >= 4U << srv_page_size_shift); - buf= static_cast<byte*>(ut_malloc_dontdump(srv_log_buffer_size * 2)); + buf= static_cast<byte*>(ut_malloc_dontdump(srv_log_buffer_size * 2, PSI_INSTRUMENT_ME)); TRASH_ALLOC(buf, srv_log_buffer_size * 2); first_in_use= true; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index c6211acb5a5..9dd54c945b9 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1008,7 +1008,7 @@ void recv_sys_t::create() apply_batch_on = false; max_log_blocks = buf_pool_get_n_pages() / 3; - buf = static_cast<byte*>(ut_malloc_dontdump(RECV_PARSING_BUF_SIZE)); + buf = static_cast<byte*>(ut_malloc_dontdump(RECV_PARSING_BUF_SIZE, PSI_INSTRUMENT_ME)); len = 0; parse_start_lsn = 0; scanned_lsn = 0; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 5351f6ea673..0ccc651cc0e 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -527,7 +527,7 @@ static int table2maria(TABLE *table_arg, data_file_type row_type, if (row_type == BLOCK_RECORD) options|= HA_OPTION_PACK_RECORD; - if (!(my_multi_malloc(MYF(MY_WME), + if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF), keydef_out, share->keys * sizeof(MARIA_KEYDEF), &keyseg, diff --git a/storage/maria/lockman.c b/storage/maria/lockman.c index 590935967af..2eeb3c339bf 100644 --- a/storage/maria/lockman.c +++ b/storage/maria/lockman.c @@ -554,7 +554,7 @@ static void initialize_bucket(LOCKMAN *lm, LOCK * volatile *node, { int res; uint parent= my_clear_highest_bit(bucket); - LOCK *dummy= (LOCK *)my_malloc(sizeof(LOCK), MYF(MY_WME)); + LOCK *dummy= (LOCK *)my_malloc(PSI_INSTRUMENT_ME, sizeof(LOCK), MYF(MY_WME)); LOCK **tmp= 0, *cur; LOCK * volatile *el= lf_dynarray_lvalue(&lm->array, parent); diff --git a/storage/maria/ma_backup.c b/storage/maria/ma_backup.c index 79270425b38..83b521b1cad 100644 --- a/storage/maria/ma_backup.c +++ b/storage/maria/ma_backup.c @@ -59,7 +59,7 @@ int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap) Allocate space for header information and for data that is too big to keep on stack */ - if (!(disc_cache= my_malloc(info_length, MYF(MY_WME)))) + if (!(disc_cache= my_malloc(PSI_NOT_INSTRUMENTED, info_length, MYF(MY_WME)))) DBUG_RETURN(ENOMEM); if (my_pread(kfile, disc_cache, info_length, 0L, MYF(MY_NABP))) diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index e9e07a56706..fd98adcaa1a 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -238,8 +238,8 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file, size*= 2; #endif - if (((bitmap->map= (uchar*) my_malloc(size, MYF(MY_WME))) == NULL) || - my_init_dynamic_array(&bitmap->pinned_pages, + if (!((bitmap->map= (uchar*) my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_WME)))) || + my_init_dynamic_array(&bitmap->pinned_pages, PSI_INSTRUMENT_ME, sizeof(MARIA_PINNED_PAGE), 1, 1, MYF(0))) return 1; diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index be7634f7521..f827846298c 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -491,7 +491,7 @@ my_bool _ma_init_block_record(MARIA_HA *info) uint default_extents; DBUG_ENTER("_ma_init_block_record"); - if (!my_multi_malloc(MY_WME, + if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), &row->empty_bits, share->base.pack_bytes, &row->field_lengths, share->base.max_field_lengths + 2, @@ -530,12 +530,13 @@ my_bool _ma_init_block_record(MARIA_HA *info) FULL_PAGE_SIZE(share) / BLOB_SEGMENT_MIN_SIZE)); - if (my_init_dynamic_array(&info->bitmap_blocks, + if (my_init_dynamic_array(&info->bitmap_blocks, PSI_INSTRUMENT_ME, sizeof(MARIA_BITMAP_BLOCK), default_extents, 64, MYF(0))) goto err; info->cur_row.extents_buffer_length= default_extents * ROW_EXTENT_SIZE; - if (!(info->cur_row.extents= my_malloc(info->cur_row.extents_buffer_length, + if (!(info->cur_row.extents= my_malloc(PSI_INSTRUMENT_ME, + info->cur_row.extents_buffer_length, MYF(MY_WME)))) goto err; @@ -3235,7 +3236,7 @@ static my_bool write_block_record(MARIA_HA *info, } else { - if (!my_multi_malloc(MY_WME, &log_array, + if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), &log_array, (uint) ((bitmap_blocks->count + TRANSLOG_INTERNAL_PARTS + 2) * sizeof(*log_array)), @@ -5256,7 +5257,8 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info) */ if (!(info->scan.bitmap_buff || ((info->scan.bitmap_buff= - (uchar *) my_malloc(share->block_size * 2, MYF(MY_WME)))))) + (uchar *) my_malloc(PSI_INSTRUMENT_ME, share->block_size * 2, + MYF(MY_WME)))))) DBUG_RETURN(1); info->scan.page_buff= info->scan.bitmap_buff + share->block_size; info->scan.bitmap_end= info->scan.bitmap_buff + share->bitmap.max_total_size; @@ -5311,7 +5313,8 @@ int _ma_scan_remember_block_record(MARIA_HA *info, DBUG_ENTER("_ma_scan_remember_block_record"); if (!(info->scan_save)) { - if (!(info->scan_save= my_malloc(ALIGN_SIZE(sizeof(*info->scan_save)) + + if (!(info->scan_save= my_malloc(PSI_INSTRUMENT_ME, + ALIGN_SIZE(sizeof(*info->scan_save)) + info->s->block_size * 2, MYF(MY_WME)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -7129,7 +7132,8 @@ my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn, row.blob_length= ma_get_length(&header); /* We need to build up a record (without blobs) in rec_buff */ - if (!(record= my_malloc(share->base.reclength, MYF(MY_WME)))) + if (!(record= my_malloc(PSI_INSTRUMENT_ME, share->base.reclength, + MYF(MY_WME)))) DBUG_RETURN(1); memcpy(record, null_bits, share->base.null_bytes); @@ -7354,7 +7358,8 @@ my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn, field_length_data_end= header; /* Allocate buffer for current row & original row */ - if (!(current_record= my_malloc(share->base.reclength * 2, MYF(MY_WME)))) + if (!(current_record= my_malloc(PSI_INSTRUMENT_ME, share->base.reclength * 2, + MYF(MY_WME)))) DBUG_RETURN(1); orig_record= current_record+ share->base.reclength; diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 8b4e34816d5..6f202e2a406 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2078,7 +2078,8 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info, my_bool extend) puts("- check record links"); } - if (!(record= (uchar*) my_malloc(share->base.default_rec_buff_size, MYF(0)))) + if (!(record= (uchar*) my_malloc(PSI_INSTRUMENT_ME, + share->base.default_rec_buff_size, MYF(0)))) { _ma_check_print_error(param,"Not enough memory for record"); DBUG_RETURN(-1); @@ -2688,7 +2689,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, } if (!(sort_param.record= - (uchar *) my_malloc((uint) + (uchar *) my_malloc(PSI_INSTRUMENT_ME, (uint) share->base.default_rec_buff_size, MYF(0))) || _ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size, share->base.default_rec_buff_size)) @@ -3628,7 +3629,7 @@ int maria_filecopy(HA_CHECK *param, File to,File from,my_off_t start, DBUG_ENTER("maria_filecopy"); buff_length=(ulong) MY_MIN(param->write_buffer_length,length); - if (!(buff=my_malloc(buff_length,MYF(0)))) + if (!(buff=my_malloc(PSI_INSTRUMENT_ME, buff_length, MYF(0)))) { buff=tmp_buff; buff_length=IO_SIZE; } @@ -3772,7 +3773,8 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, } if (!(sort_param.record= - (uchar*) my_malloc((size_t) share->base.default_rec_buff_size, + (uchar*) my_malloc(PSI_INSTRUMENT_ME, + (size_t) share->base.default_rec_buff_size, MYF(0))) || _ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size, share->base.default_rec_buff_size)) @@ -3792,7 +3794,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, param->read_cache.end_of_file= sort_info.filelength; sort_param.wordlist=NULL; - init_alloc_root(&sort_param.wordroot, "sort", FTPARSER_MEMROOT_ALLOC_SIZE, 0, + init_alloc_root(PSI_INSTRUMENT_ME, &sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(param->malloc_flags)); sort_param.key_cmp=sort_key_cmp; @@ -4356,7 +4358,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, del=share->state.state.del; if (!(sort_param=(MARIA_SORT_PARAM *) - my_malloc((uint) share->base.keys * + my_malloc(PSI_INSTRUMENT_ME, (uint) share->base.keys * (sizeof(MARIA_SORT_PARAM) + share->base.pack_reclength), MYF(MY_ZEROFILL)))) { @@ -4440,8 +4442,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, (FT_MAX_WORD_LEN_FOR_SORT * sort_param[i].keyinfo->seg->charset->mbmaxlen); sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN; - init_alloc_root(&sort_param[i].wordroot, "sort", - FTPARSER_MEMROOT_ALLOC_SIZE, 0, + init_alloc_root(PSI_INSTRUMENT_ME, &sort_param[i].wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(param->malloc_flags)); } } @@ -5423,7 +5424,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param) MARIA_DYN_DELETE_BLOCK_HEADER; if (sort_info->buff_length < reclength) { - if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength, + if (!(sort_info->buff=my_realloc(PSI_INSTRUMENT_ME, sort_info->buff, (uint) reclength, MYF(MY_FREE_ON_ERROR | MY_ALLOW_ZERO_PTR)))) DBUG_RETURN(1); @@ -5649,7 +5650,7 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param, share->rec_reflength) && (share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))) - ft_buf= (MA_SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length + + ft_buf= (MA_SORT_FT_BUF *)my_malloc(PSI_INSTRUMENT_ME, sort_param->keyinfo->block_length + sizeof(MA_SORT_FT_BUF), MYF(MY_WME)); if (!ft_buf) @@ -5975,9 +5976,8 @@ static MA_SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks, MA_SORT_KEY_BLOCKS *block; DBUG_ENTER("alloc_key_blocks"); - if (!(block= (MA_SORT_KEY_BLOCKS*) my_malloc((sizeof(MA_SORT_KEY_BLOCKS)+ - buffer_length+IO_SIZE)*blocks, - MYF(0)))) + if (!(block= (MA_SORT_KEY_BLOCKS*) my_malloc(PSI_INSTRUMENT_ME, + (sizeof(MA_SORT_KEY_BLOCKS)+buffer_length+IO_SIZE)*blocks, MYF(0)))) { _ma_check_print_error(param,"Not enough memory for sort-key-blocks"); return(0); @@ -6309,7 +6309,7 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info, We have to use an allocated buffer instead of info->rec_buff as _ma_put_key_in_record() may use info->rec_buff */ - if (!(record= (uchar*) my_malloc((size_t) share->base.default_rec_buff_size, + if (!(record= (uchar*) my_malloc(PSI_INSTRUMENT_ME, (size_t) share->base.default_rec_buff_size, MYF(0)))) { _ma_check_print_error(param,"Not enough memory for extra record"); @@ -6972,7 +6972,7 @@ static void print_bitmap_description(MARIA_SHARE *share, pgcache_page_no_t page, uchar *bitmap_data) { - char *tmp= my_malloc(MAX_BITMAP_INFO_LENGTH, MYF(MY_WME)); + char *tmp= my_malloc(PSI_INSTRUMENT_ME, MAX_BITMAP_INFO_LENGTH, MYF(MY_WME)); if (!tmp) return; _ma_get_bitmap_description(&share->bitmap, bitmap_data, page, tmp); diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c index e525602f7a1..caf6656c000 100644 --- a/storage/maria/ma_checkpoint.c +++ b/storage/maria/ma_checkpoint.c @@ -790,7 +790,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon) } } if (unlikely((distinct_shares= - (MARIA_SHARE **)my_malloc(nb * sizeof(MARIA_SHARE *), + (MARIA_SHARE **)my_malloc(PSI_INSTRUMENT_ME, nb * sizeof(MARIA_SHARE *), MYF(MY_WME))) == NULL)) goto err; for (total_names_length= 0, i= 0, pos= maria_open_list; pos; pos= pos->next) @@ -823,7 +823,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon) LSN_STORE_SIZE + /* first_log_write_at_lsn */ 1 /* end-of-name 0 */ ) * nb + total_names_length; - if (unlikely((str->str= my_malloc(str->length, MYF(MY_WME))) == NULL)) + if (unlikely((str->str= my_malloc(PSI_INSTRUMENT_ME, str->length, MYF(MY_WME))) == NULL)) goto err; ptr= str->str; @@ -853,12 +853,12 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon) */ #define STATE_COPIES 1024 state_copies= (struct st_state_copy *) - my_malloc(STATE_COPIES * sizeof(struct st_state_copy), MYF(MY_WME)); - dfiles= (PAGECACHE_FILE *)my_realloc((uchar *)dfiles, + my_malloc(PSI_INSTRUMENT_ME, STATE_COPIES * sizeof(struct st_state_copy), MYF(MY_WME)); + dfiles= (PAGECACHE_FILE *)my_realloc(PSI_INSTRUMENT_ME, (uchar *)dfiles, /* avoid size of 0 for my_realloc */ MY_MAX(1, nb) * sizeof(PAGECACHE_FILE), MYF(MY_WME | MY_ALLOW_ZERO_PTR)); - kfiles= (PAGECACHE_FILE *)my_realloc((uchar *)kfiles, + kfiles= (PAGECACHE_FILE *)my_realloc(PSI_INSTRUMENT_ME, (uchar *)kfiles, /* avoid size of 0 for my_realloc */ MY_MAX(1, nb) * sizeof(PAGECACHE_FILE), MYF(MY_WME | MY_ALLOW_ZERO_PTR)); diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index 27be555ab70..d66e3bda4de 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -213,7 +213,7 @@ int maria_close(register MARIA_HA *info) wrong status information. */ if ((history= (MARIA_STATE_HISTORY_CLOSED *) - my_malloc(sizeof(*history), MYF(MY_WME)))) + my_malloc(PSI_INSTRUMENT_ME, sizeof(*history), MYF(MY_WME)))) { history->create_rename_lsn= share->state.create_rename_lsn; history->state_history= share->state_history; diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index 06139ed564d..a13190b0220 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -145,7 +145,8 @@ int maria_create(const char *name, enum data_file_type datafile_type, } if (!(rec_per_key_part= - (double*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) + + (double*) my_malloc(PSI_INSTRUMENT_ME, + (keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) + (keys + uniques)*HA_MAX_KEY_SEG*sizeof(ulong) + sizeof(uint16) * columns, MYF(MY_WME | MY_ZEROFILL)))) @@ -1028,7 +1029,8 @@ int maria_create(const char *name, enum data_file_type datafile_type, { /* Store columns in a more efficent order */ MARIA_COLUMNDEF **col_order, **pos; - if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(share.base.fields * + if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(PSI_INSTRUMENT_ME, + share.base.fields * sizeof(MARIA_COLUMNDEF*), MYF(MY_WME)))) goto err; @@ -1090,7 +1092,8 @@ int maria_create(const char *name, enum data_file_type datafile_type, log_array[TRANSLOG_INTERNAL_PARTS + 1].length= 1 + 2 + 2 + (uint) kfile_size_before_extension; /* we are needing maybe 64 kB, so don't use the stack */ - log_data= my_malloc(log_array[TRANSLOG_INTERNAL_PARTS + 1].length, MYF(0)); + log_data= my_malloc(PSI_INSTRUMENT_ME, + log_array[TRANSLOG_INTERNAL_PARTS + 1].length, MYF(0)); if ((log_data == NULL) || mysql_file_pread(file, 1 + 2 + 2 + log_data, (size_t) kfile_size_before_extension, 0, MYF(MY_NABP))) diff --git a/storage/maria/ma_crypt.c b/storage/maria/ma_crypt.c index 95b84d38221..48861485012 100644 --- a/storage/maria/ma_crypt.c +++ b/storage/maria/ma_crypt.c @@ -101,7 +101,7 @@ int ma_crypt_create(MARIA_SHARE* share) { MARIA_CRYPT_DATA *crypt_data= - (MARIA_CRYPT_DATA*)my_malloc(sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL)); + (MARIA_CRYPT_DATA*)my_malloc(PSI_INSTRUMENT_ME, sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL)); crypt_data->scheme.type= CRYPT_SCHEME_1; crypt_data->scheme.locker= crypt_data_scheme_locker; mysql_mutex_init(key_CRYPT_DATA_lock, &crypt_data->lock, MY_MUTEX_INIT_FAST); @@ -165,7 +165,7 @@ ma_crypt_read(MARIA_SHARE* share, uchar *buff) { /* opening a table */ MARIA_CRYPT_DATA *crypt_data= - (MARIA_CRYPT_DATA*)my_malloc(sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL)); + (MARIA_CRYPT_DATA*)my_malloc(PSI_INSTRUMENT_ME, sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL)); crypt_data->scheme.type= type; mysql_mutex_init(key_CRYPT_DATA_lock, &crypt_data->lock, @@ -189,7 +189,7 @@ static int ma_decrypt(MARIA_SHARE *, MARIA_CRYPT_DATA *, const uchar *, static my_bool ma_crypt_pre_read_hook(PAGECACHE_IO_HOOK_ARGS *args) { MARIA_SHARE *share= (MARIA_SHARE*) args->data; - uchar *crypt_buf= my_malloc(share->block_size, MYF(0)); + uchar *crypt_buf= my_malloc(PSI_INSTRUMENT_ME, share->block_size, MYF(0)); if (crypt_buf == NULL) { args->crypt_buf= NULL; /* for post-hook */ @@ -260,7 +260,7 @@ static my_bool ma_crypt_data_pre_write_hook(PAGECACHE_IO_HOOK_ARGS *args) MARIA_SHARE *share= (MARIA_SHARE*) args->data; const uint size= share->block_size; uint key_version; - uchar *crypt_buf= my_malloc(share->block_size, MYF(0)); + uchar *crypt_buf= my_malloc(PSI_INSTRUMENT_ME, share->block_size, MYF(0)); if (crypt_buf == NULL) { @@ -385,7 +385,7 @@ static my_bool ma_crypt_index_pre_write_hook(PAGECACHE_IO_HOOK_ARGS *args) const uint block_size= share->block_size; const uint page_used= _ma_get_page_used(share, args->page); uint key_version; - uchar *crypt_buf= my_malloc(block_size, MYF(0)); + uchar *crypt_buf= my_malloc(PSI_INSTRUMENT_ME, block_size, MYF(0)); if (crypt_buf == NULL) { args->crypt_buf= NULL; /* for post-hook */ diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c index 70ab6b2e3f6..596c50ee497 100644 --- a/storage/maria/ma_ft_boolean_search.c +++ b/storage/maria/ma_ft_boolean_search.c @@ -561,7 +561,7 @@ FT_INFO * maria_ft_init_boolean_search(MARIA_HA *info, uint keynr, FTB_EXPR *ftbe; FTB_WORD *ftbw; - if (!(ftb=(FTB *)my_malloc(sizeof(FTB), MYF(MY_WME)))) + if (!(ftb=(FTB *)my_malloc(PSI_INSTRUMENT_ME, sizeof(FTB), MYF(MY_WME)))) return 0; ftb->please= (struct _ft_vft *) & _ma_ft_vft_boolean; ftb->state=UNINITIALIZED; @@ -574,7 +574,7 @@ FT_INFO * maria_ft_init_boolean_search(MARIA_HA *info, uint keynr, bzero(& ftb->no_dupes, sizeof(TREE)); ftb->last_word= 0; - init_alloc_root(&ftb->mem_root, "fulltext", 1024, 1024, 0); + init_alloc_root(PSI_INSTRUMENT_ME, &ftb->mem_root, 1024, 1024, 0); ftb->queue.max_elements= 0; if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR)))) goto err; diff --git a/storage/maria/ma_ft_nlq_search.c b/storage/maria/ma_ft_nlq_search.c index f7aa3afec9a..6c4e30bca83 100644 --- a/storage/maria/ma_ft_nlq_search.c +++ b/storage/maria/ma_ft_nlq_search.c @@ -291,7 +291,7 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, uchar *query, If ndocs == 0, this will not allocate RAM for FT_INFO.doc[], so if ndocs == 0, FT_INFO.doc[] must not be accessed. */ - dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+ + dlist=(FT_INFO *)my_malloc(PSI_INSTRUMENT_ME, sizeof(FT_INFO)+ sizeof(FT_DOC)* (int)(aio.dtree.elements_in_tree-1), MYF(0)); diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c index 2dfb4a77557..00532af0b47 100644 --- a/storage/maria/ma_ft_parser.c +++ b/storage/maria/ma_ft_parser.c @@ -347,9 +347,9 @@ MYSQL_FTPARSER_PARAM* maria_ftparser_alloc_param(MARIA_HA *info) (ftb_check_phrase_internal, ftb_phrase_add_word). Thus MAX_PARAM_NR=2. */ info->ftparser_param= (MYSQL_FTPARSER_PARAM *) - my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) * + my_malloc(PSI_INSTRUMENT_ME, MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) * info->s->ftkeys, MYF(MY_WME | MY_ZEROFILL)); - init_alloc_root(&info->ft_memroot, "fulltext_parser", + init_alloc_root(PSI_INSTRUMENT_ME, &info->ft_memroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(0)); } return info->ftparser_param; diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c index 12d39db806a..76b6959629b 100644 --- a/storage/maria/ma_init.c +++ b/storage/maria/ma_init.c @@ -72,7 +72,8 @@ int maria_init(void) maria_create_trn_hook= dummy_maria_create_trn_hook; } my_hash_init(&maria_stored_state, &my_charset_bin, 32, - 0, sizeof(LSN), 0, (my_hash_free_key) history_state_free, 0); + 0, sizeof(LSN), 0, (my_hash_free_key) history_state_free, 0, + PSI_INSTRUMENT_ME); DBUG_PRINT("info",("dummy_transaction_object: %p", &dummy_transaction_object)); return 0; diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index a55026e3251..f1d0703de6c 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -1649,7 +1649,7 @@ static void translog_file_init(TRANSLOG_FILE *file, uint32 number, static my_bool translog_create_new_file() { - TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(sizeof(TRANSLOG_FILE), + TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_FILE), MYF(0)); TRANSLOG_FILE *old= get_current_logfile(); @@ -3660,9 +3660,9 @@ my_bool translog_init_with_table(const char *directory, &log_descriptor.new_goal_cond, 0) || mysql_rwlock_init(key_TRANSLOG_DESCRIPTOR_open_files_lock, &log_descriptor.open_files_lock) || - my_init_dynamic_array(&log_descriptor.open_files, + my_init_dynamic_array(&log_descriptor.open_files, PSI_INSTRUMENT_ME, sizeof(TRANSLOG_FILE*), 10, 10, MYF(0)) || - my_init_dynamic_array(&log_descriptor.unfinished_files, + my_init_dynamic_array(&log_descriptor.unfinished_files, PSI_INSTRUMENT_ME, sizeof(struct st_file_counter), 10, 10, MYF(0))) goto err; @@ -3814,7 +3814,7 @@ my_bool translog_init_with_table(const char *directory, We can't allocate all file together because they will be freed one by one */ - TRANSLOG_FILE *file= (TRANSLOG_FILE *)my_malloc(sizeof(TRANSLOG_FILE), + TRANSLOG_FILE *file= (TRANSLOG_FILE *)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_FILE), MYF(0)); compile_time_assert(MY_FILEPOS_ERROR > 0xffffffffULL); @@ -4016,8 +4016,8 @@ my_bool translog_init_with_table(const char *directory, logs_found, old_log_was_recovered)); if (!logs_found) { - TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(sizeof(TRANSLOG_FILE), - MYF(MY_WME)); + TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(PSI_INSTRUMENT_ME, + sizeof(TRANSLOG_FILE), MYF(MY_WME)); DBUG_PRINT("info", ("The log is not found => we will create new log")); if (file == NULL) goto err; @@ -4084,7 +4084,7 @@ my_bool translog_init_with_table(const char *directory, Log records will refer to a MARIA_SHARE by a unique 2-byte id; set up structures for generating 2-byte ids: */ - id_to_share= (MARIA_SHARE **) my_malloc(SHARE_ID_MAX * sizeof(MARIA_SHARE*), + id_to_share= (MARIA_SHARE **) my_malloc(PSI_INSTRUMENT_ME, SHARE_ID_MAX * sizeof(MARIA_SHARE*), MYF(MY_WME | MY_ZEROFILL)); if (unlikely(!id_to_share)) goto err; @@ -5649,7 +5649,7 @@ translog_write_variable_record_mgroup(LSN *lsn, used_buffs_init(&cursor.buffs); chunk2_header[0]= TRANSLOG_CHUNK_NOHDR; - if (my_init_dynamic_array(&groups, + if (my_init_dynamic_array(&groups, PSI_INSTRUMENT_ME, sizeof(struct st_translog_group_descriptor), 10, 10, MYF(0))) { @@ -6994,7 +6994,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset, DBUG_PRINT("info", ("multi-group")); grp_no= buff->groups_no= uint2korr(src + 2); if (!(buff->groups= - (TRANSLOG_GROUP*) my_malloc(sizeof(TRANSLOG_GROUP) * grp_no, + (TRANSLOG_GROUP*) my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_GROUP) * grp_no, MYF(0)))) DBUG_RETURN(RECHEADER_READ_ERROR); DBUG_PRINT("info", ("Groups: %u", (uint) grp_no)); diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index c7080daa265..08590b9b3f6 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -117,7 +117,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, errpos= 5; /* alloc and set up private structure parts */ - if (!my_multi_malloc(MY_WME, + if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), &m_info,sizeof(MARIA_HA), &info.blobs,sizeof(MARIA_BLOB)*share->base.blobs, &info.buff,(share->base.max_key_block_length*2+ @@ -166,7 +166,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, goto err; /* The following should be big enough for all pinning purposes */ - if (my_init_dynamic_array(&info.pinned_pages, + if (my_init_dynamic_array(&info.pinned_pages, PSI_INSTRUMENT_ME, sizeof(MARIA_PINNED_PAGE), MY_MAX(share->base.blobs*2 + 4, MARIA_MAX_TREE_LEVELS*3), 16, MYF(0))) @@ -465,7 +465,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, Allocate space for header information and for data that is too big to keep on stack */ - if (!(disk_cache= my_malloc(info_length+128, MYF(MY_WME)))) + if (!(disk_cache= my_malloc(PSI_INSTRUMENT_ME, info_length+128, MYF(MY_WME)))) { my_errno=ENOMEM; goto err; @@ -648,7 +648,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, share->index_file_name.length= strlen(index_name); share->data_file_name.length= strlen(data_name); share->open_file_name.length= strlen(name); - if (!my_multi_malloc(MY_WME, + if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), &share,sizeof(*share), &rec_per_key_part, sizeof(double) * key_parts, @@ -1043,7 +1043,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, { /* Table is not part of any active transaction; Create new history */ if (!(share->state_history= (MARIA_STATE_HISTORY *) - my_malloc(sizeof(*share->state_history), MYF(MY_WME)))) + my_malloc(PSI_INSTRUMENT_ME, sizeof(*share->state_history), + MYF(MY_WME)))) goto err; share->state_history->trid= 0; /* Visible by all */ share->state_history->state= share->state.state; @@ -1244,7 +1245,7 @@ my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size, if (*old_size < new_size) { uchar *addr; - if (!(addr= (uchar*) my_realloc(*old_addr, new_size, + if (!(addr= (uchar*) my_realloc(PSI_INSTRUMENT_ME, *old_addr, new_size, MYF(MY_ALLOW_ZERO_PTR)))) return 1; *old_addr= addr; @@ -1636,7 +1637,7 @@ static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state) /* Allocate memory for key parts if not already done */ if (!state->rec_per_key_part && - !my_multi_malloc(MY_WME, + !my_multi_malloc(PSI_INSTRUMENT_ME, MY_WME, &state->rec_per_key_part, sizeof(*state->rec_per_key_part) * key_parts, &state->nulls_per_key_part, diff --git a/storage/maria/ma_packrec.c b/storage/maria/ma_packrec.c index 2e7add8f61d..b2cf7fb697a 100644 --- a/storage/maria/ma_packrec.c +++ b/storage/maria/ma_packrec.c @@ -228,7 +228,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file, - Distinct column values */ if (!(share->decode_trees=(MARIA_DECODE_TREE*) - my_malloc((uint) (trees*sizeof(MARIA_DECODE_TREE)+ + my_malloc(PSI_INSTRUMENT_ME, (uint) (trees*sizeof(MARIA_DECODE_TREE)+ intervall_length*sizeof(uchar)), MYF(MY_WME)))) goto err0; @@ -244,7 +244,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file, */ length=(uint) (elements*2+trees*(1 << maria_quick_table_bits)); if (!(share->decode_tables=(uint16*) - my_malloc((length+OFFSET_TABLE_SIZE)*sizeof(uint16)+ + my_malloc(PSI_INSTRUMENT_ME, (length+OFFSET_TABLE_SIZE)*sizeof(uint16)+ (uint) (share->pack.header_length - sizeof(header)) + share->base.extra_rec_buff_size, MYF(MY_WME | MY_ZEROFILL)))) @@ -291,9 +291,9 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file, goto err3; /* Reallocate the decoding tables to the used size. */ decode_table=(uint16*) - my_realloc((uchar*) share->decode_tables, + my_realloc(PSI_INSTRUMENT_ME, (uchar*) share->decode_tables, (uint) ((uchar*) decode_table - (uchar*) share->decode_tables), - MYF(MY_HOLD_ON_ERROR)); + MYF(0)); /* Fix the table addresses in the tree heads. */ { my_ptrdiff_t diff= PTR_BYTE_DIFF(decode_table,share->decode_tables); diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index 13a2f18cc94..72ca4da98fb 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -792,7 +792,7 @@ size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem, my_hash_init(&pagecache->files_in_flush, &my_charset_bin, 32, offsetof(struct st_file_in_flush, file), sizeof(((struct st_file_in_flush *)NULL)->file), - NULL, NULL, 0)) + NULL, NULL, 0, PSI_INSTRUMENT_ME)) goto err; pagecache->inited= 1; pagecache->in_init= 0; @@ -853,7 +853,7 @@ size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem, Allocate memory for blocks, hash_links and hash entries; For each block 2 hash links are allocated */ - if (my_multi_malloc_large(MYF(MY_ZEROFILL), + if (my_multi_malloc_large(PSI_INSTRUMENT_ME, MYF(MY_ZEROFILL), &pagecache->block_root, (ulonglong) (blocks * sizeof(PAGECACHE_BLOCK_LINK)), @@ -2330,7 +2330,7 @@ static void add_pin(PAGECACHE_BLOCK_LINK *block) #ifndef DBUG_OFF { PAGECACHE_PIN_INFO *info= - (PAGECACHE_PIN_INFO *)my_malloc(sizeof(PAGECACHE_PIN_INFO), MYF(0)); + (PAGECACHE_PIN_INFO *)my_malloc(PSI_INSTRUMENT_ME, sizeof(PAGECACHE_PIN_INFO), MYF(0)); info->thread= my_thread_var; info_link(&block->pin_list, info); } @@ -2364,7 +2364,7 @@ static void remove_pin(PAGECACHE_BLOCK_LINK *block, my_bool any static void info_add_lock(PAGECACHE_BLOCK_LINK *block, my_bool wl) { PAGECACHE_LOCK_INFO *info= - (PAGECACHE_LOCK_INFO *)my_malloc(sizeof(PAGECACHE_LOCK_INFO), MYF(0)); + (PAGECACHE_LOCK_INFO *)my_malloc(PSI_INSTRUMENT_ME, sizeof(PAGECACHE_LOCK_INFO), MYF(0)); info->thread= my_thread_var; info->write_lock= wl; info_link((PAGECACHE_PIN_INFO **)&block->lock_list, @@ -4939,7 +4939,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, if (count > FLUSH_CACHE && !(cache= (PAGECACHE_BLOCK_LINK**) - my_malloc(sizeof(PAGECACHE_BLOCK_LINK*)*count, MYF(0)))) + my_malloc(PSI_INSTRUMENT_ME, sizeof(PAGECACHE_BLOCK_LINK*)*count, MYF(0)))) { cache= cache_buff; count= FLUSH_CACHE; @@ -5295,7 +5295,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, 5 + /* pageno */ LSN_STORE_SIZE /* rec_lsn */ ) * stored_list_size; - if (NULL == (str->str= my_malloc(str->length, MYF(MY_WME)))) + if (NULL == (str->str= my_malloc(PSI_INSTRUMENT_ME, str->length, MYF(MY_WME)))) goto err; ptr= str->str; int8store(ptr, (ulonglong)stored_list_size); diff --git a/storage/maria/ma_preload.c b/storage/maria/ma_preload.c index eefc9777be6..60fd9b09bb3 100644 --- a/storage/maria/ma_preload.c +++ b/storage/maria/ma_preload.c @@ -56,7 +56,7 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves) block_length= share->pagecache->block_size; - if (!(buff= (uchar *) my_malloc(block_length, MYF(MY_WME)))) + if (!(buff= (uchar *) my_malloc(PSI_INSTRUMENT_ME, block_length, MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); if (flush_pagecache_blocks(share->pagecache, &share->kfile, FLUSH_RELEASE)) diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 6ce158dd468..4f48cf604ac 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -152,7 +152,7 @@ static void enlarge_buffer(const TRANSLOG_HEADER_BUFFER *rec) if (log_record_buffer.length < rec->record_length) { log_record_buffer.length= rec->record_length; - log_record_buffer.str= my_realloc(log_record_buffer.str, + log_record_buffer.str= my_realloc(PSI_INSTRUMENT_ME, log_record_buffer.str, rec->record_length, MYF(MY_WME | MY_ALLOW_ZERO_PTR)); } @@ -296,10 +296,10 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn, DBUG_ASSERT(should_run_undo_phase || !take_checkpoints); DBUG_ASSERT(end_lsn == LSN_IMPOSSIBLE || should_run_undo_phase == 0); all_active_trans= (struct st_trn_for_recovery *) - my_malloc((SHORT_TRID_MAX + 1) * sizeof(struct st_trn_for_recovery), + my_malloc(PSI_INSTRUMENT_ME, (SHORT_TRID_MAX + 1) * sizeof(struct st_trn_for_recovery), MYF(MY_ZEROFILL)); all_tables= (struct st_table_for_recovery *) - my_malloc((SHARE_ID_MAX + 1) * sizeof(struct st_table_for_recovery), + my_malloc(PSI_INSTRUMENT_ME, (SHARE_ID_MAX + 1) * sizeof(struct st_table_for_recovery), MYF(MY_ZEROFILL)); save_error_handler_hook= error_handler_hook; @@ -3351,10 +3351,10 @@ static LSN parse_checkpoint_record(LSN lsn) if (my_hash_init(&all_dirty_pages, &my_charset_bin, (ulong)nb_dirty_pages, offsetof(struct st_dirty_page, file_and_page_id), sizeof(((struct st_dirty_page *)NULL)->file_and_page_id), - NULL, NULL, 0)) + NULL, NULL, 0, PSI_INSTRUMENT_ME)) return LSN_ERROR; dirty_pages_pool= - (struct st_dirty_page *)my_malloc((size_t)nb_dirty_pages * + (struct st_dirty_page *)my_malloc(PSI_INSTRUMENT_ME, (size_t)nb_dirty_pages * sizeof(struct st_dirty_page), MYF(MY_WME)); if (unlikely(dirty_pages_pool == NULL)) diff --git a/storage/maria/ma_rt_index.c b/storage/maria/ma_rt_index.c index b2efe298daa..6fddc8955c4 100644 --- a/storage/maria/ma_rt_index.c +++ b/storage/maria/ma_rt_index.c @@ -905,7 +905,7 @@ static my_bool maria_rtree_fill_reinsert_list(stPageList *ReinsertList, if (ReinsertList->n_pages == ReinsertList->m_pages) { ReinsertList->m_pages += REINSERT_BUFFER_INC; - if (!(ReinsertList->pages= (stPageLevel*)my_realloc((uchar*)ReinsertList->pages, + if (!(ReinsertList->pages= (stPageLevel*)my_realloc(PSI_INSTRUMENT_ME, (uchar*)ReinsertList->pages, ReinsertList->m_pages * sizeof(stPageLevel), MYF(MY_ALLOW_ZERO_PTR)))) goto err; } diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c index 4dc6472bd15..43882c51adc 100644 --- a/storage/maria/ma_sort.c +++ b/storage/maria/ma_sort.c @@ -194,11 +194,11 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages, } if ((sort_keys= ((uchar**) - my_malloc((size_t) (keys*(sort_length+sizeof(char*))+ + my_malloc(PSI_INSTRUMENT_ME, (size_t) (keys*(sort_length+sizeof(char*))+ HA_FT_MAXBYTELEN), MYF(0))))) { - if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, + if (my_init_dynamic_array(&buffpek, PSI_INSTRUMENT_ME, sizeof(BUFFPEK), maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0))) { my_free(sort_keys); @@ -428,11 +428,11 @@ static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param) while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); } if ((sort_keys= (uchar **) - my_malloc((size_t)(keys*(sort_length+sizeof(char*))+ + my_malloc(PSI_INSTRUMENT_ME, (size_t)(keys*(sort_length+sizeof(char*))+ ((sort_param->keyinfo->flag & HA_FULLTEXT) ? HA_FT_MAXBYTELEN : 0)), MYF(0)))) { - if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), + if (my_init_dynamic_array(&sort_param->buffpek, PSI_INSTRUMENT_ME, sizeof(BUFFPEK), maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0))) { my_free(sort_keys); @@ -628,7 +628,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param) length=(size_t)param->sort_buffer_length; while (length >= MIN_SORT_MEMORY) { - if ((mergebuf= my_malloc((size_t) length, MYF(0)))) + if ((mergebuf= my_malloc(PSI_INSTRUMENT_ME, (size_t) length, MYF(0)))) break; length=length*3/4; } diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 2eff64ec7cd..9bf60c465b5 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -79,8 +79,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info) } /* Table was not used before, create new table state entry */ - if (!(tables= (MARIA_USED_TABLES*) my_malloc(sizeof(*tables), - MYF(MY_WME | MY_ZEROFILL)))) + if (!(tables= (MARIA_USED_TABLES*) my_malloc(PSI_INSTRUMENT_ME, + sizeof(*tables), MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(1); tables->next= trn->used_tables; trn->used_tables= tables; @@ -495,7 +495,8 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit, ensures that all history items are stored in the list in decresing trid order. */ - if (!(history= my_malloc(sizeof(*history), MYF(MY_WME)))) + if (!(history= my_malloc(PSI_INSTRUMENT_ME, sizeof(*history), + MYF(MY_WME)))) { /* purecov: begin inspected */ error= 1; diff --git a/storage/maria/ma_test2.c b/storage/maria/ma_test2.c index 7b7b31a7738..d739cc4a7f1 100644 --- a/storage/maria/ma_test2.c +++ b/storage/maria/ma_test2.c @@ -1215,7 +1215,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer, if (use_blob) { if (! *blob_buffer && - !(*blob_buffer=my_malloc((uint) use_blob,MYF(MY_WME)))) + !(*blob_buffer=my_malloc(PSI_NOT_INSTRUMENTED, (uint) use_blob,MYF(MY_WME)))) { use_blob= 0; return; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 92d90d5c426..9f8c0771f0b 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -892,8 +892,9 @@ ChangeSet@1.2562, 2008-04-09 07:41:40+02:00, serg@janus.mylan +9 -0 { /* Yup. converting */ info->ft1_to_ft2=(DYNAMIC_ARRAY *) - my_malloc(sizeof(DYNAMIC_ARRAY), MYF(MY_WME)); - my_init_dynamic_array(info->ft1_to_ft2, ft2len, 300, 50, MYF(0)); + my_malloc(PSI_INSTRUMENT_ME, sizeof(DYNAMIC_ARRAY), MYF(MY_WME)); + my_init_dynamic_array(info->ft1_to_ft2, PSI_INSTRUMENT_ME, ft2len, 300, + 50, MYF(0)); /* Now, adding all keys from the page to dynarray @@ -1768,7 +1769,7 @@ int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows) cache_size/=total_keylength*16; info->bulk_insert=(TREE *) - my_malloc((sizeof(TREE)*share->base.keys+ + my_malloc(PSI_INSTRUMENT_ME, (sizeof(TREE)*share->base.keys+ sizeof(bulk_insert_param)*num_keys),MYF(0)); if (!info->bulk_insert) diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index bd62859f66b..25ad7c5c86a 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -1900,8 +1900,8 @@ static int maria_sort_records(HA_CHECK *param, goto err; } - if (!(sort_param.record= - (uchar*) my_malloc((uint) share->base.default_rec_buff_size, MYF(0)))) + if (!(sort_param.record= (uchar*) my_malloc(PSI_INSTRUMENT_ME, + (uint) share->base.default_rec_buff_size, MYF(0)))) { _ma_check_print_error(param,"Not enough memory for record"); goto err; diff --git a/storage/maria/maria_pack.c b/storage/maria/maria_pack.c index 5bdeca327dd..fd8e6e5818c 100644 --- a/storage/maria/maria_pack.c +++ b/storage/maria/maria_pack.c @@ -441,7 +441,7 @@ static my_bool open_maria_files(PACK_MRG_INFO *mrg,char **names,uint count) uint i,j; mrg->count=0; mrg->current=0; - mrg->file=(MARIA_HA**) my_malloc(sizeof(MARIA_HA*)*count,MYF(MY_FAE)); + mrg->file=(MARIA_HA**) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MARIA_HA*)*count,MYF(MY_FAE)); mrg->free_file=1; mrg->src_file_has_indexes_disabled= 0; for (i=0; i < count ; i++) @@ -528,7 +528,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) < 0) goto err; length=(uint) share->base.keystart; - if (!(buff= (uchar*) my_malloc(length,MYF(MY_WME)))) + if (!(buff= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length, MYF(MY_WME)))) goto err; if (my_pread(share->kfile.file, buff, length, 0L, MYF(MY_WME | MY_NABP)) || my_write(join_maria_file,buff,length, @@ -775,9 +775,8 @@ static HUFF_COUNTS *init_huff_count(MARIA_HA *info,my_off_t records) { reg2 uint i; reg1 HUFF_COUNTS *count; - if ((count = (HUFF_COUNTS*) my_malloc(info->s->base.fields* - sizeof(HUFF_COUNTS), - MYF(MY_ZEROFILL | MY_WME)))) + if ((count = (HUFF_COUNTS*) my_malloc(PSI_NOT_INSTRUMENTED, + info->s->base.fields*sizeof(HUFF_COUNTS), MYF(MY_ZEROFILL | MY_WME)))) { for (i=0 ; i < info->s->base.fields ; i++) { @@ -804,7 +803,8 @@ static HUFF_COUNTS *init_huff_count(MARIA_HA *info,my_off_t records) NULL, MYF(0)); if (records && type != FIELD_BLOB && type != FIELD_VARCHAR) count[col_nr].tree_pos=count[col_nr].tree_buff = - my_malloc(count[col_nr].field_length > 1 ? tree_buff_length : 2, + my_malloc(PSI_NOT_INSTRUMENTED, + count[col_nr].field_length > 1 ? tree_buff_length : 2, MYF(MY_WME)); } } @@ -1448,8 +1448,8 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees) HUFF_TREE *huff_tree; DBUG_ENTER("make_huff_trees"); - if (!(huff_tree=(HUFF_TREE*) my_malloc(trees*sizeof(HUFF_TREE), - MYF(MY_WME | MY_ZEROFILL)))) + if (!(huff_tree=(HUFF_TREE*) my_malloc(PSI_NOT_INSTRUMENTED, + trees*sizeof(HUFF_TREE), MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(0); for (tree=0 ; tree < trees ; tree++) @@ -1526,16 +1526,15 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) if (!huff_tree->element_buffer) { if (!(huff_tree->element_buffer= - (HUFF_ELEMENT*) my_malloc(found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME)))) + (HUFF_ELEMENT*) my_malloc(PSI_NOT_INSTRUMENTED, + found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME)))) return 1; } else { HUFF_ELEMENT *temp; - if (!(temp= - (HUFF_ELEMENT*) my_realloc((uchar*) huff_tree->element_buffer, - found*2*sizeof(HUFF_ELEMENT), - MYF(MY_WME)))) + if (!(temp= (HUFF_ELEMENT*) my_realloc(PSI_NOT_INSTRUMENTED, + (uchar*) huff_tree->element_buffer, found*2*sizeof(HUFF_ELEMENT), MYF(MY_WME)))) return 1; huff_tree->element_buffer=temp; } @@ -1901,8 +1900,8 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree, uint trees) { elements=huff_tree->counts->tree_buff ? huff_tree->elements : 256; if (!(huff_tree->code = - (ulonglong*) my_malloc(elements* - (sizeof(ulonglong) + sizeof(uchar)), + (ulonglong*) my_malloc(PSI_NOT_INSTRUMENTED, + elements* (sizeof(ulonglong) + sizeof(uchar)), MYF(MY_WME | MY_ZEROFILL)))) return 1; huff_tree->code_len=(uchar*) (huff_tree->code+elements); @@ -2803,8 +2802,8 @@ static char *make_old_name(char *new_name, char *old_name) static void init_file_buffer(File file, pbool read_buffer) { file_buffer.file=file; - file_buffer.buffer= (uchar*) my_malloc(ALIGN_SIZE(RECORD_CACHE_SIZE), - MYF(MY_WME)); + file_buffer.buffer= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, + ALIGN_SIZE(RECORD_CACHE_SIZE), MYF(MY_WME)); file_buffer.end=file_buffer.buffer+ALIGN_SIZE(RECORD_CACHE_SIZE)-8; file_buffer.pos_in_file=0; error_on_write=0; @@ -2860,7 +2859,8 @@ static int flush_buffer(ulong neaded_length) { uchar *tmp; neaded_length+=256; /* some margin */ - tmp= (uchar*) my_realloc(file_buffer.buffer, neaded_length,MYF(MY_WME)); + tmp= (uchar*) my_realloc(PSI_NOT_INSTRUMENTED, file_buffer.buffer, + neaded_length,MYF(MY_WME)); if (!tmp) return 1; file_buffer.pos= (tmp + (ulong) (file_buffer.pos - file_buffer.buffer)); diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c index f0dc331cf10..ad7aa5ceedc 100644 --- a/storage/maria/maria_read_log.c +++ b/storage/maria/maria_read_log.c @@ -318,7 +318,8 @@ get_one_option(const struct my_option *opt, if (!my_hash_inited(&tables_to_redo)) { my_hash_init2(&tables_to_redo, 16, &my_charset_bin, - 16, 0, 0, my_hash_get_string, 0, 0, HASH_UNIQUE); + 16, 0, 0, my_hash_get_string, 0, 0, HASH_UNIQUE, + PSI_INSTRUMENT_ME); } do { diff --git a/storage/maria/test_ma_backup.c b/storage/maria/test_ma_backup.c index 4d0599dfc46..ce43109a38b 100644 --- a/storage/maria/test_ma_backup.c +++ b/storage/maria/test_ma_backup.c @@ -113,7 +113,7 @@ static int copy_table(const char *table_name, int stage) cap.online_backup_safe); printf("- Copying index file\n"); - copy_buffer= my_malloc(cap.block_size, MYF(0)); + copy_buffer= my_malloc(PSI_NOT_INSTRUMENTED, cap.block_size, MYF(0)); for (block= 0 ; ; block++) { if ((error= aria_read_index(org_file, &cap, block, copy_buffer) == diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c index 6bc83a9ba88..c018205f25e 100644 --- a/storage/maria/trnman.c +++ b/storage/maria/trnman.c @@ -149,7 +149,7 @@ int trnman_init(TrID initial_trid) DBUG_ENTER("trnman_init"); DBUG_PRINT("enter", ("initial_trid: %lu", (ulong) initial_trid)); - short_trid_to_active_trn= (TRN **)my_malloc(SHORT_TRID_MAX*sizeof(TRN*), + short_trid_to_active_trn= (TRN **)my_malloc(PSI_INSTRUMENT_ME, SHORT_TRID_MAX*sizeof(TRN*), MYF(MY_WME|MY_ZEROFILL)); if (unlikely(!short_trid_to_active_trn)) DBUG_RETURN(1); @@ -312,7 +312,7 @@ TRN *trnman_new_trn(WT_THD *wt) (Like redo_lns, which is assumed to be 0 at start of row handling and reset to zero before end of row handling) */ - trn= (TRN *)my_malloc(sizeof(TRN), MYF(MY_WME | MY_ZEROFILL)); + trn= (TRN *)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRN), MYF(MY_WME | MY_ZEROFILL)); if (unlikely(!trn)) { DBUG_PRINT("info", ("mysql_mutex_unlock LOCK_trn_list")); @@ -700,8 +700,8 @@ my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com, #endif LSN_STORE_SIZE /* first_undo_lsn */ ) * trnman_committed_transactions; - if ((NULL == (str_act->str= my_malloc(str_act->length, MYF(MY_WME)))) || - (NULL == (str_com->str= my_malloc(str_com->length, MYF(MY_WME))))) + if ((NULL == (str_act->str= my_malloc(PSI_INSTRUMENT_ME, str_act->length, MYF(MY_WME)))) || + (NULL == (str_com->str= my_malloc(PSI_INSTRUMENT_ME, str_com->length, MYF(MY_WME))))) goto err; /* First, the active transactions */ ptr= str_act->str + 2 + LSN_STORE_SIZE; diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index 00e6efad0e6..4cd62c52d86 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -576,11 +576,11 @@ int simple_delete_flush_test() int simple_big_test() { - unsigned char *buffw= (unsigned char *) my_malloc(TEST_PAGE_SIZE, MYF(MY_WME)); - unsigned char *buffr= (unsigned char *) my_malloc(TEST_PAGE_SIZE, MYF(MY_WME)); + unsigned char *buffw= (unsigned char *) my_malloc(PSI_NOT_INSTRUMENTED, TEST_PAGE_SIZE, MYF(MY_WME)); + unsigned char *buffr= (unsigned char *) my_malloc(PSI_NOT_INSTRUMENTED, TEST_PAGE_SIZE, MYF(MY_WME)); struct file_desc *desc= ((struct file_desc *) - my_malloc((PCACHE_SIZE/(TEST_PAGE_SIZE/2) + 1) * - sizeof(struct file_desc), MYF(MY_WME))); + my_malloc(PSI_NOT_INSTRUMENTED, + (PCACHE_SIZE/(TEST_PAGE_SIZE/2) + 1) * sizeof(struct file_desc), MYF(MY_WME))); int res, i; DBUG_ENTER("simple_big_test"); diff --git a/storage/maria/unittest/sequence_storage.c b/storage/maria/unittest/sequence_storage.c index c6c8caefca1..a9719d03a5d 100644 --- a/storage/maria/unittest/sequence_storage.c +++ b/storage/maria/unittest/sequence_storage.c @@ -33,7 +33,7 @@ my_bool seq_storage_reader_init(SEQ_STORAGE *seq, const char *file) seq->pos= 0; if ((fd= my_fopen(file, O_RDONLY, MYF(MY_WME))) == NULL) return 1; - if (my_init_dynamic_array(&seq->seq, sizeof(ulong), 10, 10, MYF(0))) + if (my_init_dynamic_array(&seq->seq, PSI_NOT_INSTRUMENTED, sizeof(ulong), 10, 10, MYF(0))) return 1; for(;;) diff --git a/storage/maria/unittest/test_file.c b/storage/maria/unittest/test_file.c index 354f691aaa9..8c9a5f66a2f 100644 --- a/storage/maria/unittest/test_file.c +++ b/storage/maria/unittest/test_file.c @@ -38,7 +38,7 @@ int test_file(PAGECACHE_FILE file, char *file_name, off_t size, size_t buff_size, struct file_desc *desc) { - unsigned char *buffr= my_malloc(buff_size, MYF(0)); + unsigned char *buffr= my_malloc(PSI_NOT_INSTRUMENTED, buff_size, MYF(0)); off_t pos= 0; size_t byte; int step= 0; diff --git a/storage/maria/unittest/trnman-t.c b/storage/maria/unittest/trnman-t.c index 00e84cb2456..e16d41b5821 100644 --- a/storage/maria/unittest/trnman-t.c +++ b/storage/maria/unittest/trnman-t.c @@ -80,7 +80,7 @@ void run_test(const char *test, pthread_handler handler, int n, int m) litmus= 0; - threads= (pthread_t *)my_malloc(sizeof(void *)*n, MYF(0)); + threads= (pthread_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(void *)*n, MYF(0)); if (!threads) { diag("Out of memory"); diff --git a/storage/mroonga/mrn_mysql_compat.h b/storage/mroonga/mrn_mysql_compat.h index bdb15637e31..a90b1a169e9 100644 --- a/storage/mroonga/mrn_mysql_compat.h +++ b/storage/mroonga/mrn_mysql_compat.h @@ -60,19 +60,8 @@ # define KEY_N_KEY_PARTS(key) (key)->key_parts #endif -#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100213 # define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \ - init_alloc_root(PTR, "mroonga", SZ1, SZ2, FLAG) -#elif defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000 -# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \ - init_alloc_root(PTR, SZ1, SZ2, FLAG) -#elif MYSQL_VERSION_ID >= 50706 -# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \ - init_alloc_root(mrn_memory_key, PTR, SZ1, SZ2) -#else -# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \ - init_alloc_root(PTR, SZ1, SZ2) -#endif + init_alloc_root(mrn_memory_key, PTR, SZ1, SZ2, FLAG) #if MYSQL_VERSION_ID < 100002 || !defined(MRN_MARIADB_P) # define GTS_TABLE 0 @@ -144,9 +133,7 @@ # define MRN_SEVERITY_WARNING Sql_condition::WARN_LEVEL_WARN #endif -#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P) -# define MRN_HAVE_PSI_MEMORY_KEY -#endif +#define MRN_HAVE_PSI_MEMORY_KEY #ifdef MRN_HAVE_PSI_MEMORY_KEY # define mrn_my_malloc(size, flags) \ @@ -240,40 +227,11 @@ ((select_lex)->options) #endif -#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000 -# if MYSQL_VERSION_ID >= 100213 -# define mrn_init_sql_alloc(thd, mem_root) \ - init_sql_alloc(mem_root, "Mroonga", \ - TABLE_ALLOC_BLOCK_SIZE, \ - 0, \ - MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC)) -#elif MYSQL_VERSION_ID >= 100104 # define mrn_init_sql_alloc(thd, mem_root) \ - init_sql_alloc(mem_root, \ + init_sql_alloc(mrn_memory_key, mem_root, \ TABLE_ALLOC_BLOCK_SIZE, \ 0, \ MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC)) -# else -# define mrn_init_sql_alloc(thd, mem_root) \ - init_sql_alloc(mem_root, \ - TABLE_ALLOC_BLOCK_SIZE, \ - 0, \ - MYF(0)) -# endif -#else -# if MYSQL_VERSION_ID >= 50709 -# define mrn_init_sql_alloc(thd, mem_root) \ - init_sql_alloc(mrn_memory_key, \ - mem_root, \ - TABLE_ALLOC_BLOCK_SIZE, \ - 0) -# else -# define mrn_init_sql_alloc(thd, mem_root) \ - init_sql_alloc(mem_root, \ - TABLE_ALLOC_BLOCK_SIZE, \ - 0) -# endif -#endif #ifdef MRN_MARIADB_P # define MRN_ABORT_ON_WARNING(thd) thd->abort_on_warning @@ -288,7 +246,6 @@ #define MRN_ERROR_CODE_DATA_TRUNCATE(thd) \ (MRN_ABORT_ON_WARNING(thd) ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED) -#if MYSQL_VERSION_ID >= 50709 && !defined(MRN_MARIADB_P) # define mrn_my_hash_init(hash, \ charset, \ default_array_elements, \ @@ -306,24 +263,6 @@ free_element, \ flags, \ mrn_memory_key) -#else -# define mrn_my_hash_init(hash, \ - charset, \ - default_array_elements, \ - key_offset, \ - key_length, \ - get_key, \ - free_element, \ - flags) \ - my_hash_init(hash, \ - charset, \ - default_array_elements, \ - key_offset, \ - key_length, \ - get_key, \ - free_element, \ - flags) -#endif #if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000 # define mrn_strconvert(from_cs, \ diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 406a9bbc951..a91467c5b8d 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -566,7 +566,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query, FTB_EXPR *ftbe; FTB_WORD *ftbw; - if (!(ftb=(FTB *)my_malloc(sizeof(FTB), MYF(MY_WME)))) + if (!(ftb=(FTB *)my_malloc(mi_key_memory_FTB, sizeof(FTB), MYF(MY_WME)))) return 0; ftb->please= (struct _ft_vft *) & _ft_vft_boolean; ftb->state=UNINITIALIZED; @@ -579,7 +579,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query, bzero(& ftb->no_dupes, sizeof(TREE)); ftb->last_word= 0; - init_alloc_root(&ftb->mem_root, "fulltext", 1024, 1024, MYF(0)); + init_alloc_root(mi_key_memory_FTB, &ftb->mem_root, 1024, 1024, MYF(0)); ftb->queue.max_elements= 0; if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR)))) goto err; diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 3e433b71761..eb95d1e0b94 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -287,7 +287,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query, If ndocs == 0, this will not allocate RAM for FT_INFO.doc[], so if ndocs == 0, FT_INFO.doc[] must not be accessed. */ - dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+ + dlist=(FT_INFO *)my_malloc(mi_key_memory_FT_INFO, sizeof(FT_INFO)+ sizeof(FT_DOC)* (int)(aio.dtree.elements_in_tree-1), MYF(0)); diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 9f62250f760..4584dbd4b91 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -341,9 +341,10 @@ MYSQL_FTPARSER_PARAM* ftparser_alloc_param(MI_INFO *info) (ftb_check_phrase_internal, ftb_phrase_add_word). Thus MAX_PARAM_NR=2. */ info->ftparser_param= (MYSQL_FTPARSER_PARAM *) - my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) * - info->s->ftkeys, MYF(MY_WME | MY_ZEROFILL)); - init_alloc_root(&info->ft_memroot, "fulltext_parser", + my_malloc(mi_key_memory_FTPARSER_PARAM, + MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) * info->s->ftkeys, + MYF(MY_WME | MY_ZEROFILL)); + init_alloc_root(mi_key_memory_ft_memroot, &info->ft_memroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(0)); } return info->ftparser_param; diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 3422a82a111..34c445cc163 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -59,7 +59,8 @@ int ft_init_stopwords() DBUG_ENTER("ft_init_stopwords"); if (!stopwords3) { - if (!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0)))) + if (!(stopwords3=(TREE *)my_malloc(mi_key_memory_ft_stopwords, + sizeof(TREE), MYF(0)))) DBUG_RETURN(-1); init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp, (ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0), @@ -89,13 +90,15 @@ int ft_init_stopwords() DBUG_RETURN(-1); len=(size_t)my_seek(fd, 0L, MY_SEEK_END, MYF(0)); my_seek(fd, 0L, MY_SEEK_SET, MYF(0)); - if (!(start=buffer=my_malloc(len+1, MYF(MY_WME)))) + if (!(start= buffer= my_malloc(mi_key_memory_ft_stopwords, len+1, + MYF(MY_WME)))) goto err0; len=my_read(fd, buffer, len, MYF(MY_WME)); end=start+len; while (ft_simple_get_word(ft_stopword_cs, &start, end, &w, TRUE)) { - if (ft_add_stopword(my_strndup((char*) w.pos, w.len, MYF(0)))) + if (ft_add_stopword(my_strndup(mi_key_memory_ft_stopwords, + (char*) w.pos, w.len, MYF(0)))) goto err1; } error=0; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 38091dae0ba..1e9aadf038b 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -254,7 +254,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, TABLE_SHARE *share= table_arg->s; uint options= share->db_options_in_use; DBUG_ENTER("table2myisam"); - if (!(my_multi_malloc(MYF(MY_WME), + if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF), keydef_out, share->keys * sizeof(MI_KEYDEF), &keyseg, diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 3f3c60a4249..88c6a4837e4 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -2139,7 +2139,7 @@ int filecopy(HA_CHECK *param, File to,File from,my_off_t start, DBUG_ENTER("filecopy"); buff_length=(ulong) MY_MIN(param->write_buffer_length,length); - if (!(buff=my_malloc(buff_length,MYF(0)))) + if (!(buff=my_malloc(mi_key_memory_filecopy, buff_length, MYF(0)))) { buff=tmp_buff; buff_length=IO_SIZE; } @@ -2294,8 +2294,8 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0)); sort_param.wordlist=NULL; - init_alloc_root(&sort_param.wordroot, "sort", FTPARSER_MEMROOT_ALLOC_SIZE, 0, - MYF(param->malloc_flags)); + init_alloc_root(mi_key_memory_MI_SORT_PARAM_wordroot, &sort_param.wordroot, + FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(param->malloc_flags)); if (share->data_file_type == DYNAMIC_RECORD) length=MY_MAX(share->base.min_pack_length+1,share->base.min_block_length); @@ -2789,7 +2789,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, if (share->options & HA_OPTION_COMPRESS_RECORD) set_if_bigger(max_pack_reclength, share->max_pack_length); if (!(sort_param=(MI_SORT_PARAM *) - my_malloc((uint) share->base.keys * + my_malloc(mi_key_memory_MI_SORT_PARAM, (uint) share->base.keys * (sizeof(MI_SORT_PARAM) + max_pack_reclength), MYF(MY_ZEROFILL)))) { @@ -2872,8 +2872,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT* sort_param[i].keyinfo->seg->charset->mbmaxlen; sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN; - init_alloc_root(&sort_param[i].wordroot, "sort", - FTPARSER_MEMROOT_ALLOC_SIZE, 0, + init_alloc_root(mi_key_memory_MI_SORT_PARAM_wordroot, + &sort_param[i].wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(param->malloc_flags)); } } @@ -3717,7 +3717,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param) MI_DYN_DELETE_BLOCK_HEADER; if (sort_info->buff_length < reclength) { - if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength, + if (!(sort_info->buff=my_realloc(mi_key_memory_SORT_INFO_buffer, + sort_info->buff, (uint) reclength, MYF(MY_FREE_ON_ERROR | MY_WME | MY_ALLOW_ZERO_PTR)))) DBUG_RETURN(1); @@ -3934,7 +3935,8 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) sort_info->info->s->rec_reflength) && (sort_info->info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))) - ft_buf=(SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length + + ft_buf=(SORT_FT_BUF *)my_malloc(mi_key_memory_SORT_FT_BUF, + sort_param->keyinfo->block_length + sizeof(SORT_FT_BUF), MYF(MY_WME)); if (!ft_buf) @@ -4205,7 +4207,8 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks, SORT_KEY_BLOCKS *block; DBUG_ENTER("alloc_key_blocks"); - if (!(block=(SORT_KEY_BLOCKS*) my_malloc((sizeof(SORT_KEY_BLOCKS)+ + if (!(block=(SORT_KEY_BLOCKS*) my_malloc(mi_key_memory_SORT_KEY_BLOCKS, + (sizeof(SORT_KEY_BLOCKS)+ buffer_length+IO_SIZE)*blocks, MYF(0)))) { diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index c91c1af5f60..fcdb4569f4c 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -94,7 +94,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ci->reloc_rows=ci->max_rows; /* Check if wrong parameter */ if (!(rec_per_key_part= - (ulong*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(long), + (ulong*) my_malloc(mi_key_memory_MYISAM_SHARE, + (keys + uniques) * HA_MAX_KEY_SEG * sizeof(long), MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(my_errno); diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 69c13ab96cf..09c10040f9c 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -43,7 +43,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, /* Play it safe; We have a small stack when using threads */ #undef my_alloca #undef my_afree -#define my_alloca(A) my_malloc((A),MYF(0)) +#define my_alloca(A) my_malloc(PSI_NOT_INSTRUMENTED, (A),MYF(0)) #define my_afree(A) my_free((A)) /* Interface function from MI_INFO */ diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 4d3c227dcc3..cca2afa0b03 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -310,7 +310,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) /* Add space for node pointer */ share->base.max_key_length+= share->base.key_reflength; - if (!my_multi_malloc(MY_WME, + if (!my_multi_malloc(mi_key_memory_MYISAM_SHARE, MYF(MY_WME), &share,sizeof(*share), &share->state.rec_per_key_part, sizeof(long)*base_key_parts, @@ -599,7 +599,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } /* alloc and set up private structure parts */ - if (!my_multi_malloc(MY_WME, + if (!my_multi_malloc(mi_key_memory_MI_INFO, MYF(MY_WME), &m_info,sizeof(MI_INFO), &info.blobs,sizeof(MI_BLOB)*share->base.blobs, &info.buff,(share->base.max_key_block_length*2+ @@ -759,7 +759,8 @@ uchar *mi_alloc_rec_buff(MI_INFO *info, ulong length, uchar **buf) MI_REC_BUFF_OFFSET : 0); if (extra && newptr) newptr-= MI_REC_BUFF_OFFSET; - if (!(newptr=(uchar*) my_realloc((uchar*)newptr, length+extra+8, + if (!(newptr=(uchar*) my_realloc(mi_key_memory_record_buffer, + (uchar*)newptr, length + extra + 8, MYF(MY_ALLOW_ZERO_PTR)))) return NULL; *((uint32 *) newptr)= (uint32) length; @@ -1004,7 +1005,7 @@ uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state) if (!state->rec_per_key_part) { - if (!my_multi_malloc(MY_WME, + if (!my_multi_malloc(mi_key_memory_MYISAM_SHARE, MYF(MY_WME), &state->rec_per_key_part,sizeof(long)*key_parts, &state->key_root, keys*sizeof(my_off_t), &state->key_del, key_blocks*sizeof(my_off_t), diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index b28eaf21090..637b1e69bfd 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -195,8 +195,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) - Distinct column values */ if (!(share->decode_trees=(MI_DECODE_TREE*) - my_malloc((uint) (trees*sizeof(MI_DECODE_TREE)+ - intervall_length*sizeof(uchar)), + my_malloc(mi_key_memory_MI_DECODE_TREE, + trees*sizeof(MI_DECODE_TREE) + intervall_length*sizeof(uchar), MYF(MY_WME)))) goto err0; intervall_buff=(uchar*) (share->decode_trees+trees); @@ -218,7 +218,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) data, we add (BITS_SAVED / 8) - 1 bytes to the buffer size. */ if (!(share->decode_tables=(uint16*) - my_malloc((length + OFFSET_TABLE_SIZE) * sizeof(uint16) + + my_malloc(mi_key_memory_MYISAM_SHARE_decode_tables, + (length + OFFSET_TABLE_SIZE) * sizeof(uint16) + (uint) (share->pack.header_length - sizeof(header) + (BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL)))) goto err1; @@ -258,9 +259,10 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) goto err3; /* Reallocate the decoding tables to the used size. */ decode_table=(uint16*) - my_realloc((uchar*) share->decode_tables, + my_realloc(mi_key_memory_MYISAM_SHARE_decode_tables, + (uchar*) share->decode_tables, (uint) ((uchar*) decode_table - (uchar*) share->decode_tables), - MYF(MY_HOLD_ON_ERROR)); + MYF(0)); /* Fix the table addresses in the tree heads. */ { my_ptrdiff_t diff=PTR_BYTE_DIFF(decode_table,share->decode_tables); diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c index d52a2ea46ea..5f9132abe14 100644 --- a/storage/myisam/mi_preload.c +++ b/storage/myisam/mi_preload.c @@ -73,7 +73,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) length= info->preload_buff_size/block_length * block_length; set_if_bigger(length, block_length); - if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) + if (!(buff= (uchar *) my_malloc(mi_key_memory_preload_buffer, length, + MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); if (flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c index 3679ea4a329..d0c3995d9de 100644 --- a/storage/myisam/mi_static.c +++ b/storage/myisam/mi_static.c @@ -61,6 +61,28 @@ uint myisam_readnext_vec[]= SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER }; +PSI_memory_key mi_key_memory_MYISAM_SHARE; +PSI_memory_key mi_key_memory_MI_INFO; +PSI_memory_key mi_key_memory_MI_INFO_ft1_to_ft2; +PSI_memory_key mi_key_memory_MI_INFO_bulk_insert; +PSI_memory_key mi_key_memory_record_buffer; +PSI_memory_key mi_key_memory_FTB; +PSI_memory_key mi_key_memory_FT_INFO; +PSI_memory_key mi_key_memory_FTPARSER_PARAM; +PSI_memory_key mi_key_memory_ft_memroot; +PSI_memory_key mi_key_memory_ft_stopwords; +PSI_memory_key mi_key_memory_MI_SORT_PARAM; +PSI_memory_key mi_key_memory_MI_SORT_PARAM_wordroot; +PSI_memory_key mi_key_memory_SORT_FT_BUF; +PSI_memory_key mi_key_memory_SORT_KEY_BLOCKS; +PSI_memory_key mi_key_memory_filecopy; +PSI_memory_key mi_key_memory_SORT_INFO_buffer; +PSI_memory_key mi_key_memory_MI_DECODE_TREE; +PSI_memory_key mi_key_memory_MYISAM_SHARE_decode_tables; +PSI_memory_key mi_key_memory_preload_buffer; +PSI_memory_key mi_key_memory_stPageList_pages; +PSI_memory_key mi_key_memory_keycache_thread_var; + #ifdef HAVE_PSI_INTERFACE PSI_mutex_key mi_key_mutex_MYISAM_SHARE_intern_lock, mi_key_mutex_MI_SORT_INFO_mutex, mi_key_mutex_MI_CHECK_print_msg; @@ -106,6 +128,31 @@ static PSI_thread_info all_myisam_threads[]= { &mi_key_thread_find_all_keys, "find_all_keys", 0}, }; +static PSI_memory_info all_myisam_memory[]= +{ + { &mi_key_memory_MYISAM_SHARE, "MYISAM_SHARE", 0}, + { &mi_key_memory_MI_INFO, "MI_INFO", 0}, + { &mi_key_memory_MI_INFO_ft1_to_ft2, "MI_INFO::ft1_to_ft2", 0}, + { &mi_key_memory_MI_INFO_bulk_insert, "MI_INFO::bulk_insert", 0}, + { &mi_key_memory_record_buffer, "record_buffer", 0}, + { &mi_key_memory_FTB, "FTB", 0}, + { &mi_key_memory_FT_INFO, "FT_INFO", 0}, + { &mi_key_memory_FTPARSER_PARAM, "FTPARSER_PARAM", 0}, + { &mi_key_memory_ft_memroot, "ft_memroot", 0}, + { &mi_key_memory_ft_stopwords, "ft_stopwords", 0}, + { &mi_key_memory_MI_SORT_PARAM, "MI_SORT_PARAM", 0}, + { &mi_key_memory_MI_SORT_PARAM_wordroot, "MI_SORT_PARAM::wordroot", 0}, + { &mi_key_memory_SORT_FT_BUF, "SORT_FT_BUF", 0}, + { &mi_key_memory_SORT_KEY_BLOCKS, "SORT_KEY_BLOCKS", 0}, + { &mi_key_memory_filecopy, "filecopy", 0}, + { &mi_key_memory_SORT_INFO_buffer, "SORT_INFO::buffer", 0}, + { &mi_key_memory_MI_DECODE_TREE, "MI_DECODE_TREE", 0}, + { &mi_key_memory_MYISAM_SHARE_decode_tables, "MYISAM_SHARE::decode_tables", 0}, + { &mi_key_memory_preload_buffer, "preload_buffer", 0}, + { &mi_key_memory_stPageList_pages, "stPageList::pages", 0}, + { &mi_key_memory_keycache_thread_var, "keycache_thread_var", 0} +}; + void init_myisam_psi_keys() { const char* category= "myisam"; @@ -125,6 +172,9 @@ void init_myisam_psi_keys() count= array_elements(all_myisam_threads); mysql_thread_register(category, all_myisam_threads, count); + + count= array_elements(all_myisam_memory); + mysql_memory_register(category, all_myisam_memory, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 48a091e80de..5a66e958139 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -1021,7 +1021,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer) if (rnd(10) == 0) { if (! *blob_buffer && - !(*blob_buffer=my_malloc((uint) use_blob,MYF(MY_WME)))) + !(*blob_buffer=my_malloc(PSI_NOT_INSTRUMENTED, use_blob,MYF(MY_WME)))) { use_blob=0; return; diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 7345ab1604d..512a2a11bf2 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -546,8 +546,10 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, { /* yup. converting */ info->ft1_to_ft2=(DYNAMIC_ARRAY *) - my_malloc(sizeof(DYNAMIC_ARRAY), MYF(MY_WME)); - my_init_dynamic_array(info->ft1_to_ft2, ft2len, 300, 50, MYF(0)); + my_malloc(mi_key_memory_MI_INFO_ft1_to_ft2, + sizeof(DYNAMIC_ARRAY), MYF(MY_WME)); + my_init_dynamic_array(info->ft1_to_ft2, mi_key_memory_MI_INFO_ft1_to_ft2, + ft2len, 300, 50, MYF(0)); /* now, adding all keys from the page to dynarray @@ -998,7 +1000,8 @@ int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows) cache_size/=total_keylength*16; info->bulk_insert=(TREE *) - my_malloc((sizeof(TREE)*share->base.keys+ + my_malloc(mi_key_memory_MI_INFO_bulk_insert, + (sizeof(TREE)*share->base.keys+ sizeof(bulk_insert_param)*num_keys),MYF(0)); if (!info->bulk_insert) diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index b92c012e5f4..c5975f42315 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -777,4 +777,26 @@ extern PSI_thread_key mi_key_thread_find_all_keys; void init_myisam_psi_keys(); #endif /* HAVE_PSI_INTERFACE */ +extern PSI_memory_key mi_key_memory_MYISAM_SHARE; +extern PSI_memory_key mi_key_memory_MI_INFO; +extern PSI_memory_key mi_key_memory_MI_INFO_ft1_to_ft2; +extern PSI_memory_key mi_key_memory_MI_INFO_bulk_insert; +extern PSI_memory_key mi_key_memory_record_buffer; +extern PSI_memory_key mi_key_memory_FTB; +extern PSI_memory_key mi_key_memory_FT_INFO; +extern PSI_memory_key mi_key_memory_FTPARSER_PARAM; +extern PSI_memory_key mi_key_memory_ft_memroot; +extern PSI_memory_key mi_key_memory_ft_stopwords; +extern PSI_memory_key mi_key_memory_MI_SORT_PARAM; +extern PSI_memory_key mi_key_memory_MI_SORT_PARAM_wordroot; +extern PSI_memory_key mi_key_memory_SORT_FT_BUF; +extern PSI_memory_key mi_key_memory_SORT_KEY_BLOCKS; +extern PSI_memory_key mi_key_memory_filecopy; +extern PSI_memory_key mi_key_memory_SORT_INFO_buffer; +extern PSI_memory_key mi_key_memory_MI_DECODE_TREE; +extern PSI_memory_key mi_key_memory_MYISAM_SHARE_decode_tables; +extern PSI_memory_key mi_key_memory_preload_buffer; +extern PSI_memory_key mi_key_memory_stPageList_pages; +extern PSI_memory_key mi_key_memory_keycache_thread_var; + C_MODE_END diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 9bef2be929f..40d473dc532 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -422,7 +422,7 @@ static int examine_log(char * file_name, char **table_names) * The additional space is needed for the sprintf commands two lines * below. */ - file_info.show_name=my_memdup(isam_file_name, + file_info.show_name=my_memdup(PSI_NOT_INSTRUMENTED, isam_file_name, (uint) strlen(isam_file_name)+10, MYF(MY_WME)); if (file_info.id > 1) @@ -451,8 +451,8 @@ static int examine_log(char * file_name, char **table_names) if (!(file_info.isam= mi_open(isam_file_name,O_RDWR, HA_OPEN_WAIT_IF_LOCKED))) goto com_err; - if (!(file_info.record=my_malloc(file_info.isam->s->base.reclength, - MYF(MY_WME)))) + if (!(file_info.record=my_malloc(PSI_NOT_INSTRUMENTED, + file_info.isam->s->base.reclength, MYF(MY_WME)))) goto end; files_open++; file_info.closed=0; @@ -683,7 +683,7 @@ static int read_string(IO_CACHE *file, register uchar* *to, register uint length if (*to) my_free(*to); - if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) || + if (!(*to= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length+1,MYF(MY_WME))) || my_b_read(file,(uchar*) *to,length)) { if (*to) diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index b2a2909ad73..1267ddc724d 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -439,7 +439,7 @@ static my_bool open_isam_files(PACK_MRG_INFO *mrg, char **names, uint count) uint i,j; mrg->count=0; mrg->current=0; - mrg->file=(MI_INFO**) my_malloc(sizeof(MI_INFO*)*count,MYF(MY_FAE)); + mrg->file=(MI_INFO**) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MI_INFO*)*count,MYF(MY_FAE)); mrg->free_file=1; mrg->src_file_has_indexes_disabled= 0; for (i=0; i < count ; i++) @@ -518,7 +518,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) < 0) goto err; length=(uint) share->base.keystart; - if (!(buff= (uchar*) my_malloc(length,MYF(MY_WME)))) + if (!(buff= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length,MYF(MY_WME)))) goto err; if (my_pread(share->kfile,buff,length,0L,MYF(MY_WME | MY_NABP)) || my_write(join_isam_file,buff,length, @@ -798,7 +798,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records) { reg2 uint i; reg1 HUFF_COUNTS *count; - if ((count = (HUFF_COUNTS*) my_malloc(info->s->base.fields* + if ((count = (HUFF_COUNTS*) my_malloc(PSI_NOT_INSTRUMENTED, info->s->base.fields* sizeof(HUFF_COUNTS), MYF(MY_ZEROFILL | MY_WME)))) { @@ -825,7 +825,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records) NULL, MYF(0)); if (records && type != FIELD_BLOB && type != FIELD_VARCHAR) count[i].tree_pos=count[i].tree_buff = - my_malloc(count[i].field_length > 1 ? tree_buff_length : 2, + my_malloc(PSI_NOT_INSTRUMENTED, count[i].field_length > 1 ? tree_buff_length : 2, MYF(MY_WME)); } } @@ -1476,7 +1476,7 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees) HUFF_TREE *huff_tree; DBUG_ENTER("make_huff_trees"); - if (!(huff_tree=(HUFF_TREE*) my_malloc(trees*sizeof(HUFF_TREE), + if (!(huff_tree=(HUFF_TREE*) my_malloc(PSI_NOT_INSTRUMENTED, trees*sizeof(HUFF_TREE), MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(0); @@ -1554,14 +1554,14 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) if (!huff_tree->element_buffer) { if (!(huff_tree->element_buffer= - (HUFF_ELEMENT*) my_malloc(found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME)))) + (HUFF_ELEMENT*) my_malloc(PSI_NOT_INSTRUMENTED, found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME)))) return 1; } else { HUFF_ELEMENT *temp; if (!(temp= - (HUFF_ELEMENT*) my_realloc((uchar*) huff_tree->element_buffer, + (HUFF_ELEMENT*) my_realloc(PSI_NOT_INSTRUMENTED, (uchar*) huff_tree->element_buffer, found*2*sizeof(HUFF_ELEMENT), MYF(MY_WME)))) return 1; @@ -1930,7 +1930,7 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree, uint trees) { elements=huff_tree->counts->tree_buff ? huff_tree->elements : 256; if (!(huff_tree->code = - (ulonglong*) my_malloc(elements* + (ulonglong*) my_malloc(PSI_NOT_INSTRUMENTED, elements* (sizeof(ulonglong) + sizeof(uchar)), MYF(MY_WME | MY_ZEROFILL)))) return 1; @@ -2823,7 +2823,7 @@ static char *make_old_name(char *new_name, char *old_name) static void init_file_buffer(File file, pbool read_buffer) { file_buffer.file=file; - file_buffer.buffer= (uchar*) my_malloc(ALIGN_SIZE(RECORD_CACHE_SIZE), + file_buffer.buffer= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, ALIGN_SIZE(RECORD_CACHE_SIZE), MYF(MY_WME)); file_buffer.end=file_buffer.buffer+ALIGN_SIZE(RECORD_CACHE_SIZE)-8; file_buffer.pos_in_file=0; @@ -2880,7 +2880,7 @@ static int flush_buffer(ulong neaded_length) { char *tmp; neaded_length+=256; /* some margin */ - tmp= my_realloc((char*) file_buffer.buffer, neaded_length,MYF(MY_WME)); + tmp= my_realloc(PSI_NOT_INSTRUMENTED, (char*) file_buffer.buffer, neaded_length,MYF(MY_WME)); if (!tmp) return 1; file_buffer.pos= ((uchar*) tmp + diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c index 08543ec2b22..651e2e79478 100644 --- a/storage/myisam/rt_index.c +++ b/storage/myisam/rt_index.c @@ -733,8 +733,11 @@ static int rtree_fill_reinsert_list(stPageList *ReinsertList, my_off_t page, if (ReinsertList->n_pages == ReinsertList->m_pages) { ReinsertList->m_pages += REINSERT_BUFFER_INC; - if (!(ReinsertList->pages = (stPageLevel*)my_realloc((uchar*)ReinsertList->pages, - ReinsertList->m_pages * sizeof(stPageLevel), MYF(MY_ALLOW_ZERO_PTR)))) + if (!(ReinsertList->pages = (stPageLevel*) + my_realloc(mi_key_memory_stPageList_pages, + (uchar*)ReinsertList->pages, + ReinsertList->m_pages * sizeof(stPageLevel), + MYF(MY_ALLOW_ZERO_PTR)))) goto err1; } /* save page to ReinsertList */ diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index e586543363b..910867b13a8 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -190,10 +190,12 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, } if ((sort_keys= ((uchar **) - my_malloc((size_t) (keys*(sort_length+sizeof(char*))+ + my_malloc(PSI_INSTRUMENT_ME, + (size_t) (keys*(sort_length+sizeof(char*))+ HA_FT_MAXBYTELEN), MYF(0))))) { - if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, + if (my_init_dynamic_array(&buffpek, PSI_INSTRUMENT_ME, + sizeof(BUFFPEK), maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0))) { my_free(sort_keys); @@ -406,12 +408,14 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param) } while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); } - if ((sort_keys= (uchar**) my_malloc((size_t)(keys * (sort_length + sizeof(char*)) + + if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME, + (size_t)(keys * (sort_length + sizeof(char*)) + ((sort_param->keyinfo->flag & HA_FULLTEXT) ? HA_FT_MAXBYTELEN : 0)), MYF(0)))) { - if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), - maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0))) + if (my_init_dynamic_array(&sort_param->buffpek, PSI_INSTRUMENT_ME, + sizeof(BUFFPEK), maxbuffer, + MY_MIN(maxbuffer / 2, 1000), MYF(0))) { my_free(sort_keys); sort_keys= NULL; /* Safety against double free on error. */ @@ -607,7 +611,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) length=param->sort_buffer_length; while (length >= MIN_SORT_BUFFER) { - if ((mergebuf= my_malloc((size_t) length, MYF(0)))) + if ((mergebuf= my_malloc(PSI_INSTRUMENT_ME, + (size_t) length, MYF(0)))) break; length=length*3/4; } diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 14036a31b8c..4fd63020c6a 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -120,7 +120,7 @@ static handler *myisammrg_create_handler(handlerton *hton, ha_myisammrg::ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg) :handler(hton, table_arg), file(0), is_cloned(0) { - init_sql_alloc(&children_mem_root, "ha_myisammrg", + init_sql_alloc(rg_key_memory_children, &children_mem_root, FN_REFLEN + ALLOC_ROOT_MIN_BLOCK_SIZE, 0, MYF(0)); } diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h index 9ef65f220be..8bb79a73127 100644 --- a/storage/myisammrg/myrg_def.h +++ b/storage/myisammrg/myrg_def.h @@ -32,12 +32,13 @@ extern "C" #endif void myrg_print_wrong_table(const char *table_name); -#ifdef HAVE_PSI_INTERFACE +/* Always defined */ +extern PSI_memory_key rg_key_memory_MYRG_INFO; C_MODE_START extern PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex; +extern PSI_memory_key rg_key_memory_children; extern PSI_file_key rg_key_file_MRG; void init_myisammrg_psi_keys(); C_MODE_END -#endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 06c71dec14a..e19ce8f7cf3 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -108,7 +108,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) if (!m_info) /* First file */ { key_parts=isam->s->base.key_parts; - if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) + + if (!(m_info= (MYRG_INFO*) my_malloc(rg_key_memory_MYRG_INFO, + sizeof(MYRG_INFO) + files*sizeof(MYRG_TABLE) + key_parts*sizeof(long), MYF(MY_WME|MY_ZEROFILL)))) @@ -149,7 +150,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) if (bad_children) goto bad_children; - if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), + if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(rg_key_memory_MYRG_INFO, + sizeof(MYRG_INFO), MYF(MY_WME | MY_ZEROFILL)))) goto err; /* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */ @@ -285,7 +287,8 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, } /* Allocate MERGE parent table structure. */ - if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) + + if (!(m_info= (MYRG_INFO*) my_malloc(rg_key_memory_MYRG_INFO, + sizeof(MYRG_INFO) + child_count * sizeof(MYRG_TABLE), MYF(MY_WME | MY_ZEROFILL)))) goto err; /* purecov: inspected */ @@ -435,7 +438,8 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, if (!m_info->rec_per_key_part) { if(!(m_info->rec_per_key_part= (ulong*) - my_malloc(key_parts * sizeof(long), MYF(MY_WME)))) + my_malloc(rg_key_memory_MYRG_INFO, + key_parts * sizeof(long), MYF(MY_WME)))) goto err; /* purecov: inspected */ errpos= 1; } diff --git a/storage/myisammrg/myrg_static.c b/storage/myisammrg/myrg_static.c index a2f5d074c9e..36ec25cb7d9 100644 --- a/storage/myisammrg/myrg_static.c +++ b/storage/myisammrg/myrg_static.c @@ -29,6 +29,9 @@ static const char *merge_insert_methods[] = TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"", merge_insert_methods, 0}; +PSI_memory_key rg_key_memory_MYRG_INFO; +PSI_memory_key rg_key_memory_children; + #ifdef HAVE_PSI_INTERFACE PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex; @@ -44,6 +47,12 @@ static PSI_file_info all_myisammrg_files[]= { &rg_key_file_MRG, "MRG", 0} }; +static PSI_memory_info all_myisammrg_memory[]= +{ + { &rg_key_memory_MYRG_INFO, "MYRG_INFO", 0}, + { &rg_key_memory_children, "children", 0} +}; + void init_myisammrg_psi_keys() { const char* category= "myisammrg"; @@ -54,6 +63,9 @@ void init_myisammrg_psi_keys() count= array_elements(all_myisammrg_files); mysql_file_register(category, all_myisammrg_files, count); + + count= array_elements(all_myisammrg_memory); + mysql_memory_register(category, all_myisammrg_memory, count); } #endif /* HAVE_PSI_INTERFACE */ diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 20ebd49bd5d..1857b66fdfd 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -562,7 +562,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) init_tmp_table_share( thd, share, table->s->db.str, table->s->db.length, options->table_name, ""); // because of that, we need to reinitialize the memroot (to reset MY_THREAD_SPECIFIC flag) DBUG_ASSERT(share->mem_root.used == NULL); // it's still empty - init_sql_alloc(&share->mem_root, "share", TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0)); + init_sql_alloc(PSI_INSTRUMENT_ME, &share->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0)); // What I think this code is doing: // * Our OQGRAPH table is `database_blah/name` diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 8488f9ee963..625624d228e 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -5970,6 +5970,7 @@ Rdb_table_handler *Rdb_open_tables_map::get_table_handler( // Since we did not find it in the hash map, attempt to create and add it // to the hash map. if (!(table_handler = reinterpret_cast<Rdb_table_handler *>(my_multi_malloc( + PSI_INSTRUMENT_ME, MYF(MY_WME | MY_ZEROFILL), &table_handler, sizeof(*table_handler), &tmp_name, table_name_str.length() + 1, NullS)))) { // Allocating a new Rdb_table_handler and a new table name failed. @@ -6550,11 +6551,11 @@ int ha_rocksdb::alloc_key_buffers(const TABLE *const table_arg, // move this into get_table_handler() ?? m_pk_descr->setup(table_arg, tbl_def_arg); - m_pk_tuple = reinterpret_cast<uchar *>(my_malloc(key_len, MYF(0))); + m_pk_tuple = reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, key_len, MYF(0))); pack_key_len = m_pk_descr->max_storage_fmt_length(); m_pk_packed_tuple = - reinterpret_cast<uchar *>(my_malloc(pack_key_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, pack_key_len, MYF(0))); /* Sometimes, we may use m_sk_packed_tuple for storing packed PK */ max_packed_sk_len = pack_key_len; @@ -6572,20 +6573,20 @@ int ha_rocksdb::alloc_key_buffers(const TABLE *const table_arg, } m_sk_packed_tuple = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_sk_match_prefix_buf = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_sk_packed_tuple_old = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_end_key_packed_tuple = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_pack_buffer = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_scan_it_lower_bound = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_scan_it_upper_bound = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); /* If inplace alter is happening, allocate special buffers for unique @@ -6593,9 +6594,9 @@ int ha_rocksdb::alloc_key_buffers(const TABLE *const table_arg, */ if (alloc_alter_buffers) { m_dup_sk_packed_tuple = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); m_dup_sk_packed_tuple_old = - reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0))); + reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0))); } if (m_pk_tuple == nullptr || m_pk_packed_tuple == nullptr || @@ -14131,7 +14132,7 @@ void rocksdb_set_collation_exception_list(THD *const thd, rdb_set_collation_exception_list(val == nullptr ? "" : val); //psergey-todo: what is the purpose of the below?? - const char *val_copy= val? my_strdup(val, MYF(0)): nullptr; + const char *val_copy= val? my_strdup(PSI_INSTRUMENT_ME, val, MYF(0)): nullptr; my_free(*static_cast<char**>(var_ptr)); *static_cast<const char**>(var_ptr) = val_copy; } @@ -14344,7 +14345,7 @@ static int rocksdb_validate_update_cf_options( // This can cause invalid memory access after validation is finished. // To avoid this kind case, let's alway duplicate the str if str is not // nullptr - *(const char **)save = (str == nullptr) ? nullptr : my_strdup(str, MYF(0)); + *(const char **)save = (str == nullptr) ? nullptr : my_strdup(PSI_INSTRUMENT_ME, str, MYF(0)); if (str == nullptr) { return HA_EXIT_SUCCESS; diff --git a/storage/rocksdb/rdb_converter.cc b/storage/rocksdb/rdb_converter.cc index 677ff106753..e799d67f813 100644 --- a/storage/rocksdb/rdb_converter.cc +++ b/storage/rocksdb/rdb_converter.cc @@ -436,7 +436,7 @@ void Rdb_converter::setup_field_encoders() { uchar cur_null_mask = 0x1; m_encoder_arr = static_cast<Rdb_field_encoder *>( - my_malloc(m_table->s->fields * sizeof(Rdb_field_encoder), MYF(0))); + my_malloc(PSI_INSTRUMENT_ME, m_table->s->fields * sizeof(Rdb_field_encoder), MYF(0))); if (m_encoder_arr == nullptr) { return; } diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 00e6b95a748..3673a67bf22 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -368,14 +368,14 @@ Rdb_key_def::Rdb_key_def(const Rdb_key_def &k) m_total_index_flags_length == 0); if (k.m_pack_info) { const size_t size = sizeof(Rdb_field_packing) * k.m_key_parts; - void *pack_info= my_malloc(size, MYF(0)); + void *pack_info= my_malloc(PSI_INSTRUMENT_ME, size, MYF(0)); memcpy(pack_info, k.m_pack_info, size); m_pack_info = reinterpret_cast<Rdb_field_packing *>(pack_info); } if (k.m_pk_part_no) { const size_t size = sizeof(uint) * m_key_parts; - m_pk_part_no = reinterpret_cast<uint *>(my_malloc(size, MYF(0))); + m_pk_part_no = reinterpret_cast<uint *>(my_malloc(PSI_INSTRUMENT_ME, size, MYF(0))); memcpy(m_pk_part_no, k.m_pk_part_no, size); } } @@ -449,14 +449,14 @@ void Rdb_key_def::setup(const TABLE *const tbl, if (secondary_key) { m_pk_part_no = reinterpret_cast<uint *>( - my_malloc(sizeof(uint) * m_key_parts, MYF(0))); + my_malloc(PSI_INSTRUMENT_ME, sizeof(uint) * m_key_parts, MYF(0))); } else { m_pk_part_no = nullptr; } const size_t size = sizeof(Rdb_field_packing) * m_key_parts; m_pack_info = - reinterpret_cast<Rdb_field_packing *>(my_malloc(size, MYF(0))); + reinterpret_cast<Rdb_field_packing *>(my_malloc(PSI_INSTRUMENT_ME, size, MYF(0))); /* Guaranteed not to error here as checks have been made already during diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 2688b54725c..b1ef4826b59 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -596,6 +596,7 @@ private: struct Override_t { + Override_t() : m_dIds(PSI_INSTRUMENT_MEM), m_dValues(PSI_INSTRUMENT_MEM) {} union Value_t { uint32 m_uValue; @@ -738,7 +739,7 @@ static int sphinx_init_func ( void * p ) sphinx_init = 1; void ( pthread_mutex_init ( &sphinx_mutex, MY_MUTEX_INIT_FAST ) ); sphinx_hash_init ( &sphinx_open_tables, system_charset_info, 32, 0, 0, - sphinx_get_key, 0, 0 ); + sphinx_get_key, 0, 0, PSI_NOT_INSTRUMENTED ); #if MYSQL_VERSION_ID > 50100 handlerton * hton = (handlerton*) p; @@ -1303,6 +1304,7 @@ CSphSEQuery::CSphSEQuery ( const char * sQuery, int iLength, const char * sIndex , m_fGeoLongitude ( 0.0f ) , m_sComment ( (char*) "" ) , m_sSelect ( (char*) "*" ) + , m_dOverrides (PSI_INSTRUMENT_MEM) , m_pBuf ( NULL ) , m_pCur ( NULL ) diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp index 97d479220e0..f735db6f586 100644 --- a/storage/spider/hs_client/config.cpp +++ b/storage/spider/hs_client/config.cpp @@ -36,7 +36,7 @@ conf_get_key( config::config() { if (my_hash_init(&conf_hash, &my_charset_bin, 32, 0, 0, - (my_hash_get_key) conf_get_key, 0, 0)) + (my_hash_get_key) conf_get_key, 0, 0, PSI_INSTRUMENT_ME)) init = FALSE; else init = TRUE; diff --git a/storage/spider/hs_client/hs_compat.h b/storage/spider/hs_client/hs_compat.h index 8505d7978b7..6d40ff47475 100644 --- a/storage/spider/hs_client/hs_compat.h +++ b/storage/spider/hs_client/hs_compat.h @@ -16,7 +16,12 @@ #ifndef HS_COMPAT_H #define HS_COMPAT_H -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100213 +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100500 +#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ + my_init_dynamic_array2(A, PSI_INSTRUMENT_ME, B, C, D, E, F) +#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ + init_alloc_root(PSI_INSTRUMENT_ME, A, B, C, D) +#elif defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100213 #define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ my_init_dynamic_array2(A, B, C, D, E, F) #define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 3ef8d4e0725..fe0ddd1d736 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -4534,7 +4534,8 @@ SPIDER_IP_PORT_CONN* spider_create_ipport_conn(SPIDER_CONN *conn) DBUG_ENTER("spider_create_ipport_conn"); if (conn) { - SPIDER_IP_PORT_CONN *ret = (SPIDER_IP_PORT_CONN *) my_malloc(sizeof(*ret), MY_ZEROFILL | MY_WME); + SPIDER_IP_PORT_CONN *ret = (SPIDER_IP_PORT_CONN *) + my_malloc(PSI_INSTRUMENT_ME, sizeof(*ret), MY_ZEROFILL | MY_WME); if (!ret) { goto err_return_direct; @@ -4568,8 +4569,8 @@ SPIDER_IP_PORT_CONN* spider_create_ipport_conn(SPIDER_CONN *conn) goto err_malloc_key; } - ret->key = (char *) my_malloc(ret->key_len + conn->tgt_host_length + 1, - MY_ZEROFILL | MY_WME); + ret->key = (char *) my_malloc(PSI_INSTRUMENT_ME, ret->key_len + + conn->tgt_host_length + 1, MY_ZEROFILL | MY_WME); if (!ret->key) { pthread_cond_destroy(&ret->cond); pthread_mutex_destroy(&ret->mutex); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index ef405c68410..d3cf17679c3 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -1867,7 +1867,7 @@ int spider_db_mbase::init() DBUG_PRINT("info",("spider this=%p", this)); if ( my_hash_init(&lock_table_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_link_get_key, 0, 0) + (my_hash_get_key) spider_link_get_key, 0, 0, PSI_INSTRUMENT_ME) ) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc index 40b37ff4377..9f4203ae33d 100644 --- a/storage/spider/spd_malloc.cc +++ b/storage/spider/spd_malloc.cc @@ -203,7 +203,7 @@ void *spider_alloc_mem( uchar *ptr; DBUG_ENTER("spider_alloc_mem"); size += ALIGN_SIZE(sizeof(uint)) + ALIGN_SIZE(sizeof(uint)); - if (!(ptr = (uchar *) my_malloc(size, my_flags))) + if (!(ptr = (uchar *) my_malloc(PSI_INSTRUMENT_ME, size, my_flags))) DBUG_RETURN(NULL); spider_alloc_mem_calc(trx, id, func_name, file_name, line_no, size); @@ -233,7 +233,7 @@ void *spider_bulk_alloc_mem( total_size += ALIGN_SIZE(va_arg(args, uint)); va_end(args); - if (!(top_ptr = (uchar *) my_malloc(total_size, my_flags))) + if (!(top_ptr = (uchar *) my_malloc(PSI_INSTRUMENT_ME, total_size, my_flags))) DBUG_RETURN(NULL); spider_alloc_mem_calc(trx, id, func_name, file_name, line_no, total_size); diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index ee41d39df0f..e13c8d2b403 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -6139,7 +6139,8 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share( if( my_hash_init(&partition_share->pt_handler_hash, spd_charset_utf8mb3_bin, - 32, 0, 0, (my_hash_get_key) spider_pt_handler_share_get_key, 0, 0) + 32, 0, 0, (my_hash_get_key) spider_pt_handler_share_get_key, 0, 0, + PSI_INSTRUMENT_ME) ) { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_pt_handler_hash; @@ -7185,7 +7186,7 @@ int spider_db_init( goto error_mem_calc_mutex_init; if (my_hash_init(&spider_open_tables, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_tbl_get_key, 0, 0)) + (my_hash_get_key) spider_tbl_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_open_tables_hash_init; spider_alloc_calc_mem_init(spider_open_tables, 143); @@ -7194,7 +7195,7 @@ int spider_db_init( spider_open_tables.array.max_element * spider_open_tables.array.size_of_element); if (my_hash_init(&spider_init_error_tables, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_tbl_get_key, 0, 0)) + (my_hash_get_key) spider_tbl_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_init_error_tables_hash_init; spider_alloc_calc_mem_init(spider_init_error_tables, 144); @@ -7204,7 +7205,7 @@ int spider_db_init( spider_init_error_tables.array.size_of_element); #ifdef WITH_PARTITION_STORAGE_ENGINE if (my_hash_init(&spider_open_pt_share, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_pt_share_get_key, 0, 0)) + (my_hash_get_key) spider_pt_share_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_open_pt_share_hash_init; spider_alloc_calc_mem_init(spider_open_pt_share, 145); @@ -7216,7 +7217,7 @@ int spider_db_init( if (my_hash_init(&spider_lgtm_tblhnd_share_hash, spd_charset_utf8mb3_bin, 32, 0, 0, (my_hash_get_key) spider_lgtm_tblhnd_share_hash_get_key, - 0, 0)) + 0, 0, PSI_INSTRUMENT_ME)) goto error_lgtm_tblhnd_share_hash_init; spider_alloc_calc_mem_init(spider_lgtm_tblhnd_share_hash, 245); @@ -7225,12 +7226,12 @@ int spider_db_init( spider_lgtm_tblhnd_share_hash.array.max_element * spider_lgtm_tblhnd_share_hash.array.size_of_element); if (my_hash_init(&spider_open_connections, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) + (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_open_connections_hash_init; if (my_hash_init(&spider_ipport_conns, spd_charset_utf8mb3_bin, 32, 0, 0, (my_hash_get_key) spider_ipport_conn_get_key, - spider_free_ipport_conn, 0)) + spider_free_ipport_conn, 0, PSI_INSTRUMENT_ME)) goto error_ipport_conn__hash_init; spider_alloc_calc_mem_init(spider_open_connections, 146); @@ -7240,7 +7241,7 @@ int spider_db_init( spider_open_connections.array.size_of_element); #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if (my_hash_init(&spider_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) + (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_hs_r_conn_hash_init; spider_alloc_calc_mem_init(spider_hs_r_conn_hash, 147); @@ -7249,7 +7250,7 @@ int spider_db_init( spider_hs_r_conn_hash.array.max_element * spider_hs_r_conn_hash.array.size_of_element); if (my_hash_init(&spider_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) + (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_hs_w_conn_hash_init; spider_alloc_calc_mem_init(spider_hs_w_conn_hash, 148); @@ -7259,7 +7260,7 @@ int spider_db_init( spider_hs_w_conn_hash.array.size_of_element); #endif if (my_hash_init(&spider_allocated_thds, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_allocated_thds_get_key, 0, 0)) + (my_hash_get_key) spider_allocated_thds_get_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_allocated_thds_hash_init; spider_alloc_calc_mem_init(spider_allocated_thds, 149); @@ -7321,7 +7322,7 @@ int spider_db_init( { if (my_hash_init(&spider_udf_table_mon_list_hash[roop_count], spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_udf_tbl_mon_list_key, 0, 0)) + (my_hash_get_key) spider_udf_tbl_mon_list_key, 0, 0, PSI_INSTRUMENT_ME)) goto error_init_udf_table_mon_list_hash; spider_alloc_calc_mem_init(spider_udf_table_mon_list_hash, 150); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index ad2a35aac15..d3ff8424f9d 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1238,7 +1238,7 @@ SPIDER_TRX *spider_get_trx( if ( my_hash_init(&trx->trx_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0) + (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME) ) goto error_init_hash; spider_alloc_calc_mem_init(trx->trx_conn_hash, 151); @@ -1250,7 +1250,7 @@ SPIDER_TRX *spider_get_trx( if ( my_hash_init(&trx->trx_another_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0) + (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME) ) goto error_init_another_hash; spider_alloc_calc_mem_init(trx->trx_another_conn_hash, 152); @@ -1314,7 +1314,7 @@ SPIDER_TRX *spider_get_trx( if ( my_hash_init(&trx->trx_alter_table_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_alter_tbl_get_key, 0, 0) + (my_hash_get_key) spider_alter_tbl_get_key, 0, 0, PSI_INSTRUMENT_ME) ) goto error_init_alter_hash; spider_alloc_calc_mem_init(trx->trx_alter_table_hash, 157); @@ -1326,7 +1326,7 @@ SPIDER_TRX *spider_get_trx( if ( my_hash_init(&trx->trx_ha_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_trx_ha_get_key, 0, 0) + (my_hash_get_key) spider_trx_ha_get_key, 0, 0, PSI_INSTRUMENT_ME) ) goto error_init_trx_ha_hash; spider_alloc_calc_mem_init(trx->trx_ha_hash, 158); |