summaryrefslogtreecommitdiff
path: root/storage/heap
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@sun.com>2009-12-04 18:26:15 -0700
committerMarc Alff <marc.alff@sun.com>2009-12-04 18:26:15 -0700
commit57fd11788e800ca016ceb50e93c0c70eec0f6dd6 (patch)
tree9ca152d7f2ac50cfd8b7fca83f87cb06148d97a0 /storage/heap
parent34436edb4dd38f30d0f155e0a5fe484754ec5846 (diff)
downloadmariadb-git-57fd11788e800ca016ceb50e93c0c70eec0f6dd6.tar.gz
WL#2360 Performance schema
Part II, engines instrumentation
Diffstat (limited to 'storage/heap')
-rw-r--r--storage/heap/ha_heap.cc10
-rw-r--r--storage/heap/heapdef.h15
-rw-r--r--storage/heap/hp_close.c6
-rw-r--r--storage/heap/hp_create.c21
-rw-r--r--storage/heap/hp_open.c12
-rw-r--r--storage/heap/hp_panic.c6
-rw-r--r--storage/heap/hp_rename.c8
-rw-r--r--storage/heap/hp_static.c33
8 files changed, 76 insertions, 35 deletions
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 99c1ca5d2e9..8d07d21c6ae 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -39,6 +39,10 @@ int heap_init(void *p)
{
handlerton *heap_hton;
+#ifdef HAVE_PSI_INTERFACE
+ init_heap_psi_keys();
+#endif
+
heap_hton= (handlerton *)p;
heap_hton->state= SHOW_OPTION_YES;
heap_hton->db_type= DB_TYPE_HEAP;
@@ -106,9 +110,9 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
if (!file)
{
/* Couldn't open table; Remove the newly created table */
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
hp_free(internal_share);
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
}
implicit_emptied= 1;
}
diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h
index 3fc94062303..bc3c6bf7239 100644
--- a/storage/heap/heapdef.h
+++ b/storage/heap/heapdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002, 2004 MySQL AB
+/* Copyright (C) 2000-2002, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -103,9 +103,14 @@ extern void hp_clear_keys(HP_SHARE *info);
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
key_part_map keypart_map);
#ifdef THREAD
-extern pthread_mutex_t THR_LOCK_heap;
-#else
-#define pthread_mutex_lock(A)
-#define pthread_mutex_unlock(A)
+extern mysql_mutex_t THR_LOCK_heap;
#endif
+
+#ifdef HAVE_PSI_INTERFACE
+#ifdef THREAD
+extern PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock;
+#endif /* THREAD */
+void init_heap_psi_keys();
+#endif /* HAVE_PSI_INTERFACE */
+
C_MODE_END
diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c
index d571815980c..49d8ec376bb 100644
--- a/storage/heap/hp_close.c
+++ b/storage/heap/hp_close.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002 MySQL AB
+/* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,9 +24,9 @@ int heap_close(HP_INFO *info)
{
int tmp;
DBUG_ENTER("heap_close");
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
tmp= hp_close(info);
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(tmp);
}
diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c
index 1440cbc0e98..3f651d1573c 100644
--- a/storage/heap/hp_create.c
+++ b/storage/heap/hp_create.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
if (!create_info->internal_table)
{
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
if ((share= hp_find_named_heap(name)) && share->open_count == 0)
{
hp_free(share);
@@ -194,7 +194,8 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
}
#ifdef THREAD
thr_lock_init(&share->lock);
- pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(hp_key_mutex_HP_SHARE_intern_lock,
+ &share->intern_lock, MY_MUTEX_INIT_FAST);
#endif
if (!create_info->internal_table)
{
@@ -205,14 +206,14 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
share->delete_on_close= 1;
}
if (!create_info->internal_table)
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
*res= share;
DBUG_RETURN(0);
err:
if (!create_info->internal_table)
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(1);
} /* heap_create */
@@ -266,7 +267,7 @@ int heap_delete_table(const char *name)
reg1 HP_SHARE *share;
DBUG_ENTER("heap_delete_table");
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
if ((share= hp_find_named_heap(name)))
{
heap_try_free(share);
@@ -276,7 +277,7 @@ int heap_delete_table(const char *name)
{
result= my_errno=ENOENT;
}
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(result);
}
@@ -284,9 +285,9 @@ int heap_delete_table(const char *name)
void heap_drop_table(HP_INFO *info)
{
DBUG_ENTER("heap_drop_table");
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
heap_try_free(info->s);
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_VOID_RETURN;
}
@@ -298,7 +299,7 @@ void hp_free(HP_SHARE *share)
hp_clear(share); /* Remove blocks from memory */
#ifdef THREAD
thr_lock_delete(&share->lock);
- pthread_mutex_destroy(&share->intern_lock);
+ mysql_mutex_destroy(&share->intern_lock);
#endif
my_free((uchar*) share->name, MYF(0));
my_free((uchar*) share, MYF(0));
diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c
index 4d5ec6e27ac..feafa5d5cf1 100644
--- a/storage/heap/hp_open.c
+++ b/storage/heap/hp_open.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2004, 2006 MySQL AB
+/* Copyright (C) 2000-2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -69,13 +69,13 @@ HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode)
HP_INFO *info;
DBUG_ENTER("heap_open_from_share_and_register");
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
if ((info= heap_open_from_share(share, mode)))
{
info->open_list.data= (void*) info;
heap_open_list= list_add(heap_open_list,&info->open_list);
}
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(info);
}
@@ -94,11 +94,11 @@ HP_INFO *heap_open(const char *name, int mode)
HP_SHARE *share;
DBUG_ENTER("heap_open");
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
if (!(share= hp_find_named_heap(name)))
{
my_errno= ENOENT;
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0);
}
if ((info= heap_open_from_share(share, mode)))
@@ -106,7 +106,7 @@ HP_INFO *heap_open(const char *name, int mode)
info->open_list.data= (void*) info;
heap_open_list= list_add(heap_open_list,&info->open_list);
}
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(info);
}
diff --git a/storage/heap/hp_panic.c b/storage/heap/hp_panic.c
index 9a2bd2c574e..87d982dff2a 100644
--- a/storage/heap/hp_panic.c
+++ b/storage/heap/hp_panic.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002 MySQL AB
+/* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@ int hp_panic(enum ha_panic_function flag)
LIST *element,*next_open;
DBUG_ENTER("hp_panic");
- pthread_mutex_lock(&THR_LOCK_heap);
+ mysql_mutex_lock(&THR_LOCK_heap);
for (element=heap_open_list ; element ; element=next_open)
{
HP_INFO *info=(HP_INFO*) element->data;
@@ -51,6 +51,6 @@ int hp_panic(enum ha_panic_function flag)
break;
}
}
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0);
} /* hp_panic */
diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c
index c2350450e2b..c4e8390cc43 100644
--- a/storage/heap/hp_rename.c
+++ b/storage/heap/hp_rename.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002 MySQL AB
+/* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,17 +25,17 @@ int heap_rename(const char *old_name, const char *new_name)
char *name_buff;
DBUG_ENTER("heap_rename");
- pthread_mutex_lock(&THR_LOCK_heap);
+ 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))))
{
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(my_errno);
}
my_free(info->name,MYF(0));
info->name=name_buff;
}
- pthread_mutex_unlock(&THR_LOCK_heap);
+ mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0);
}
diff --git a/storage/heap/hp_static.c b/storage/heap/hp_static.c
index a501ba7e359..e1ca7d1f445 100644
--- a/storage/heap/hp_static.c
+++ b/storage/heap/hp_static.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2001 MySQL AB
+/* Copyright (C) 2000-2001 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,3 +23,34 @@
#endif
LIST *heap_open_list=0,*heap_share_list=0;
+
+#ifdef HAVE_PSI_INTERFACE
+#ifdef THREAD
+PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock;
+
+static PSI_mutex_info all_heap_mutexes[]=
+{
+ { & hp_key_mutex_HP_SHARE_intern_lock, "HP_SHARE::intern_lock", 0}
+ /*
+ Note:
+ THR_LOCK_heap is part of mysys, not storage/heap.
+ */
+};
+#endif /* THREAD */
+
+void init_heap_psi_keys()
+{
+#ifdef THREAD
+ const char* category= "memory";
+ int count;
+
+ if (PSI_server == NULL)
+ return;
+
+ count= array_elements(all_heap_mutexes);
+ PSI_server->register_mutex(category, all_heap_mutexes, count);
+#endif /* THREAD */
+}
+#endif /* HAVE_PSI_INTERFACE */
+
+