3559 Marc Alff 2011-11-03
Added benchmarks for table io and table lock
modified:
storage/perfschema/unittest/pfs_benchmark-t.cc
3558 Marc Alff 2011-11-03
Added tooling from mysql-trunk-perfschema for benchmarks
added:
storage/perfschema/unittest/doit-linux
storage/perfschema/unittest/pfs_benchmark-t.cc
storage/perfschema/unittest/pfs_benchmark_helper.cc
storage/perfschema/unittest/pfs_benchmark_helper.h
modified:
storage/perfschema/unittest/CMakeLists.txt
=== modified file 'storage/perfschema/unittest/pfs_benchmark-t.cc'
--- a/storage/perfschema/unittest/pfs_benchmark-t.cc 2011-11-03 22:38:27 +0000
+++ b/storage/perfschema/unittest/pfs_benchmark-t.cc 2011-11-04 01:12:21 +0000
@@ -42,6 +42,9 @@
#include "stub_server_misc.h"
#include "pfs_benchmark_helper.h"
+/* TABLE_SHARE */
+#include "table.h"
+
#include <string.h> /* memset */
static bool bench_pfs_enabled= false;
@@ -77,15 +80,12 @@ PSI_file_info all_bench_files[]=
{ & bench_file_key, "benchmark", 0}
};
-static PSI_thread_key key_thread_main;
+static PSI_thread_key key_bm_thread_main;
static PSI_thread_info all_bench_threads[]=
{
- { & key_thread_main, "main", 0}
+ { & key_bm_thread_main, "main", 0}
};
-// static PSI_table_share *bench_table_share= NULL;
-static PSI_table *bench_table_handle= NULL;
-
static void setup(bool pfs_enabled)
{
PFS_global_param param;
@@ -141,7 +141,7 @@ static void setup(bool pfs_enabled)
PSI_server->register_file("unittest", all_bench_files, 1);
PSI_server->register_thread("unittest", all_bench_threads, 1);
- PSI_thread *psi= PSI_server->new_thread(key_thread_main, NULL, 0);
+ PSI_thread *psi= PSI_server->new_thread(key_bm_thread_main, NULL, 0);
ok(!pfs_enabled || psi != NULL, "main thread");
PSI_server->set_thread(psi);
@@ -390,14 +390,25 @@ void benchmark_file_open(uint count, con
count, timer_cycles, timer_cycles/count);
}
-void benchmark_table_open(uint count, const char *test)
+void fake_TABLE_SHARE(TABLE_SHARE *fake)
+{
+ fake->db.str = (char*) "test";
+ fake->db.length = 4;
+ fake->table_name.str = (char*) "t1";
+ fake->table_name.length = 2;
+ fake->keys= 0;
+}
+
+void benchmark_create_table_share(uint count, const char *test)
{
ulonglong timer_start;
ulonglong timer_end;
ulonglong timer_cycles;
- PSI_table *that= bench_table_handle;
- ok(that == NULL, "table is not instrumented yet");
+ TABLE_SHARE table_share;
+ fake_TABLE_SHARE(& table_share);
+
+ PSI_table_share *that;
timer_start= my_timer_cycles();
@@ -405,18 +416,86 @@ void benchmark_table_open(uint count, co
start_some_work();
for (i= 0 ; i<count; i++)
{
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, that,
- PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
+ that= PSI_CALL(get_table_share)(false, &table_share);
do_some_work();
- MYSQL_END_TABLE_IO_WAIT(locker);
+ PSI_CALL(drop_table_share)("test", 4, "t1", 2);
}
timer_end= my_timer_cycles();
timer_cycles= timer_end-timer_start;
// ok(get_work_done() == count, "work done");
- diag("TABLE_IO benchmark: %s, %d calls, %13llu cycles, %13llu avg",
+ diag("CREATE_TABLE_SHARE benchmark: %s, %d calls, %13llu cycles, %13llu avg",
+ test,
+ count, timer_cycles, timer_cycles/count);
+}
+
+void benchmark_find_table_share(uint count, const char *test)
+{
+ ulonglong timer_start;
+ ulonglong timer_end;
+ ulonglong timer_cycles;
+
+ TABLE_SHARE table_share;
+ fake_TABLE_SHARE(& table_share);
+
+ PSI_table_share *that_1;
+ PSI_table_share *that_2;
+
+ timer_start= my_timer_cycles();
+
+ uint i;
+ start_some_work();
+ that_1= PSI_CALL(get_table_share)(false, &table_share);
+ for (i= 0 ; i<count; i++)
+ {
+ that_2= PSI_CALL(get_table_share)(false, &table_share);
+ do_some_work();
+ PSI_CALL(release_table_share)(that_2);
+ }
+ PSI_CALL(drop_table_share)("test", 4, "t1", 2);
+
+ timer_end= my_timer_cycles();
+ timer_cycles= timer_end-timer_start;
+ // ok(get_work_done() == count, "work done");
+
+ diag("FIND_TABLE_SHARE benchmark: %s, %d calls, %13llu cycles, %13llu avg",
+ test,
+ count, timer_cycles, timer_cycles/count);
+}
+
+void benchmark_open_table(uint count, const char *test)
+{
+ ulonglong timer_start;
+ ulonglong timer_end;
+ ulonglong timer_cycles;
+
+ TABLE_SHARE table_share;
+ fake_TABLE_SHARE(& table_share);
+
+ PSI_table_share *that_share;
+ that_share= PSI_CALL(get_table_share)(false, &table_share);
+
+ PSI_table *that;
+ timer_start= my_timer_cycles();
+
+ uint i;
+ start_some_work();
+ for (i= 0 ; i<count; i++)
+ {
+ that= PSI_CALL(open_table)(that_share, NULL);
+ do_some_work();
+ PSI_CALL(close_table)(that);
+ }
+
+ timer_end= my_timer_cycles();
+ timer_cycles= timer_end-timer_start;
+
+ PSI_CALL(drop_table_share)("test", 4, "t1", 2);
+
+ // ok(get_work_done() == count, "work done");
+
+ diag("OPEN_TABLE benchmark: %s, %d calls, %13llu cycles, %13llu avg",
test,
count, timer_cycles, timer_cycles/count);
}
@@ -427,8 +506,14 @@ void benchmark_table_io(uint count, cons
ulonglong timer_end;
ulonglong timer_cycles;
- PSI_table *that= bench_table_handle;
- ok(that == NULL, "table is not instrumented yet");
+ TABLE_SHARE table_share;
+ fake_TABLE_SHARE(& table_share);
+
+ PSI_table_share *that_share;
+ that_share= PSI_CALL(get_table_share)(false, &table_share);
+
+ PSI_table *that;
+ that= PSI_CALL(open_table)(that_share, NULL);
timer_start= my_timer_cycles();
@@ -447,6 +532,9 @@ void benchmark_table_io(uint count, cons
timer_cycles= timer_end-timer_start;
// ok(get_work_done() == count, "work done");
+ PSI_CALL(close_table)(that);
+ PSI_CALL(drop_table_share)("test", 4, "t1", 2);
+
diag("TABLE_IO benchmark: %s, %d calls, %13llu cycles, %13llu avg",
test,
count, timer_cycles, timer_cycles/count);
@@ -458,8 +546,14 @@ void benchmark_table_lock(uint count, co
ulonglong timer_end;
ulonglong timer_cycles;
- PSI_table *that= bench_table_handle;
- ok(that == NULL, "table is not instrumented yet");
+ TABLE_SHARE table_share;
+ fake_TABLE_SHARE(& table_share);
+
+ PSI_table_share *that_share;
+ that_share= PSI_CALL(get_table_share)(false, &table_share);
+
+ PSI_table *that;
+ that= PSI_CALL(open_table)(that_share, NULL);
timer_start= my_timer_cycles();
@@ -478,6 +572,9 @@ void benchmark_table_lock(uint count, co
timer_cycles= timer_end-timer_start;
// ok(get_work_done() == count, "work done");
+ PSI_CALL(close_table)(that);
+ PSI_CALL(drop_table_share)("test", 4, "t1", 2);
+
diag("TABLE_LOCK benchmark: %s, %d calls, %13llu cycles, %13llu avg",
test,
count, timer_cycles, timer_cycles/count);
@@ -508,6 +605,9 @@ void benchmark_all(bool enabled, bool ti
benchmark_file_read(1, msg);
benchmark_file_open(1, msg);
*/
+ benchmark_create_table_share(1, msg);
+ benchmark_find_table_share(1, msg);
+ benchmark_open_table(1, msg);
benchmark_table_io(1, msg);
benchmark_table_lock(1, msg);
@@ -518,6 +618,9 @@ void benchmark_all(bool enabled, bool ti
benchmark_file_read(1000, msg);
benchmark_file_open(1000, msg);
*/
+ benchmark_create_table_share(1000, msg);
+ benchmark_find_table_share(1000, msg);
+ benchmark_open_table(1000, msg);
benchmark_table_io(1000, msg);
benchmark_table_lock(1000, msg);
@@ -528,6 +631,9 @@ void benchmark_all(bool enabled, bool ti
benchmark_file_read(1000000, msg);
benchmark_file_open(1000000, msg);
*/
+ benchmark_create_table_share(1000000, msg);
+ benchmark_find_table_share(1000000, msg);
+ benchmark_open_table(1000000, msg);
benchmark_table_io(1000000, msg);
benchmark_table_lock(1000000, msg);
@@ -562,6 +668,10 @@ void test_all(bool enabled, bool timed)
bench_cond_class->m_timed= timed;
bench_file_class->m_enabled= enabled;
bench_file_class->m_timed= timed;
+ global_table_io_class.m_enabled= enabled;
+ global_table_io_class.m_timed= timed;
+ global_table_lock_class.m_enabled= enabled;
+ global_table_lock_class.m_timed= timed;
benchmark_all(enabled, timed, "bigbang");
@@ -584,6 +694,16 @@ void test_all(bool enabled, bool timed)
void do_print_config()
{
+#ifdef MY_ATOMIC_MODE_DUMMY
+ diag("MY_ATOMIC_MODE_DUMMY : something is wrong here");
+#endif
+
+#ifdef MY_ATOMIC_MODE_RWLOCKS
+ diag("MY_ATOMIC_MODE_RWLOCKS : something is wrong here");
+#endif
+
+ diag("MY_ATOMIC_MODE compiled with : " MY_ATOMIC_MODE);
+
#ifdef HAVE_PSI_MUTEX_INTERFACE
diag("MUTEX INSTRUMENTATION compiled in");
#else
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-marc branch (marc.alff:3558 to 3559) | Marc Alff | 7 Nov |