summaryrefslogtreecommitdiff
path: root/storage/heap
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-01-29 13:50:26 +0100
committerSergei Golubchik <serg@mariadb.org>2020-03-10 19:24:22 +0100
commit7c58e97bf6f80a251046c5b3e7bce826fe058bd6 (patch)
tree7d32d26b320cf83296ee0ede2ea164ad116c4de8 /storage/heap
parent2ac3121af2767186c489054db5d4871d04b8eef4 (diff)
downloadmariadb-git-7c58e97bf6f80a251046c5b3e7bce826fe058bd6.tar.gz
perfschema memory related instrumentation changes
Diffstat (limited to 'storage/heap')
-rw-r--r--storage/heap/ha_heap.cc3
-rw-r--r--storage/heap/heapdef.h6
-rw-r--r--storage/heap/hp_block.c2
-rw-r--r--storage/heap/hp_create.c8
-rw-r--r--storage/heap/hp_open.c4
-rw-r--r--storage/heap/hp_rename.c3
-rw-r--r--storage/heap/hp_static.c21
7 files changed, 27 insertions, 20 deletions
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 */