#At file:///home/malff/BZR-TREE/mysql-6.0-perf/ based on revid:marc.alff@stripped
2860 Marc Alff 2009-04-10
Bug#44190 Performance schema: nanosecond and ticks timers not implemented on windows
Some timers may not be implemented on all platforms, and this is an expected
edge condition that is not properly handled.
Fixed the code for non implemented timers to:
- be robust, in the timer to picosecond conversion
- display NULL in PERFORMANCE_TIMERS
Fixed the unit test my_rdtsc-t to handle non implemented timers.
modified:
scripts/mysql_system_tables.sql
storage/perfschema/pfs_timer.cc
storage/perfschema/table_performance_timers.cc
storage/perfschema/table_performance_timers.h
unittest/mysys/my_rdtsc-t.c
=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql 2009-04-08 02:07:56 +0000
+++ b/scripts/mysql_system_tables.sql 2009-04-10 18:56:32 +0000
@@ -334,9 +334,9 @@ DROP PREPARE stmt;
SET @l1="CREATE TABLE performance_schema.PERFORMANCE_TIMERS(";
SET @l2="TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null,";
-SET @l3="TIMER_FREQUENCY BIGINT not null,";
-SET @l4="TIMER_RESOLUTION BIGINT not null,";
-SET @l5="TIMER_OVERHEAD BIGINT not null";
+SET @l3="TIMER_FREQUENCY BIGINT,";
+SET @l4="TIMER_RESOLUTION BIGINT,";
+SET @l5="TIMER_OVERHEAD BIGINT";
SET @l6=") ENGINE=PERFORMANCE_SCHEMA;";
SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6);
=== modified file 'storage/perfschema/pfs_timer.cc'
--- a/storage/perfschema/pfs_timer.cc 2009-03-30 16:38:27 +0000
+++ b/storage/perfschema/pfs_timer.cc 2009-04-10 18:56:32 +0000
@@ -58,11 +58,30 @@ void init_timers()
millisec_v0= my_timer_milliseconds();
tick_v0= my_timer_ticks();
- cycle_to_pico= round_to_ulong(pico_frequency/(double)myt.cycles_frequency);
- nanosec_to_pico= round_to_ulong(pico_frequency/(double)myt.nanoseconds_frequency);
- microsec_to_pico= round_to_ulong(pico_frequency/(double)myt.microseconds_frequency);
- millisec_to_pico= round_to_ulong(pico_frequency/(double)myt.milliseconds_frequency);
- tick_to_pico= round_to_ulonglong(pico_frequency/(double)myt.ticks_frequency);
+ if (myt.cycles_frequency > 0)
+ cycle_to_pico= round_to_ulong(pico_frequency/(double)myt.cycles_frequency);
+ else
+ cycle_to_pico= 0;
+
+ if (myt.nanoseconds_frequency > 0)
+ nanosec_to_pico= round_to_ulong(pico_frequency/(double)myt.nanoseconds_frequency);
+ else
+ nanosec_to_pico= 0;
+
+ if (myt.microseconds_frequency > 0)
+ microsec_to_pico= round_to_ulong(pico_frequency/(double)myt.microseconds_frequency);
+ else
+ microsec_to_pico= 0;
+
+ if (myt.milliseconds_frequency > 0)
+ millisec_to_pico= round_to_ulong(pico_frequency/(double)myt.milliseconds_frequency);
+ else
+ millisec_to_pico= 0;
+
+ if (myt.ticks_frequency > 0)
+ tick_to_pico= round_to_ulonglong(pico_frequency/(double)myt.ticks_frequency);
+ else
+ tick_to_pico= 0;
}
ulonglong get_timer_value(enum_timer_name timer_name)
=== modified file 'storage/perfschema/table_performance_timers.cc'
--- a/storage/perfschema/table_performance_timers.cc 2009-03-29 21:38:18 +0000
+++ b/storage/perfschema/table_performance_timers.cc 2009-04-10 18:56:32 +0000
@@ -51,30 +51,35 @@ table_performance_timers::table_performa
m_row= NULL;
index= (int)TIMER_NAME_CYCLE - FIRST_TIMER_NAME;
+ m_data[index].m_routine= myt.cycles_routine;
m_data[index].m_timer_name= TIMER_NAME_CYCLE;
m_data[index].m_timer_frequency= myt.cycles_frequency;
m_data[index].m_timer_resolution= myt.cycles_resolution;
m_data[index].m_timer_overhead= myt.cycles_overhead;
index= (int)TIMER_NAME_NANOSEC - FIRST_TIMER_NAME;
+ m_data[index].m_routine= myt.nanoseconds_routine;
m_data[index].m_timer_name= TIMER_NAME_NANOSEC;
m_data[index].m_timer_frequency= myt.nanoseconds_frequency;
m_data[index].m_timer_resolution= myt.nanoseconds_resolution;
m_data[index].m_timer_overhead= myt.nanoseconds_overhead;
index= (int)TIMER_NAME_MICROSEC - FIRST_TIMER_NAME;
+ m_data[index].m_routine= myt.microseconds_routine;
m_data[index].m_timer_name= TIMER_NAME_MICROSEC;
m_data[index].m_timer_frequency= myt.microseconds_frequency;
m_data[index].m_timer_resolution= myt.microseconds_resolution;
m_data[index].m_timer_overhead= myt.microseconds_overhead;
index= (int)TIMER_NAME_MILLISEC - FIRST_TIMER_NAME;
+ m_data[index].m_routine= myt.milliseconds_routine;
m_data[index].m_timer_name= TIMER_NAME_MILLISEC;
m_data[index].m_timer_frequency= myt.milliseconds_frequency;
m_data[index].m_timer_resolution= myt.milliseconds_resolution;
m_data[index].m_timer_overhead= myt.milliseconds_overhead;
index= (int)TIMER_NAME_TICK - FIRST_TIMER_NAME;
+ m_data[index].m_routine= myt.ticks_routine;
m_data[index].m_timer_name= TIMER_NAME_TICK;
m_data[index].m_timer_frequency= myt.ticks_frequency;
m_data[index].m_timer_resolution= myt.ticks_resolution;
@@ -143,17 +148,26 @@ int table_performance_timers::read_row_v
case 1:
DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
col_timer_frequency= (Field_longlong*) f;
- col_timer_frequency->store(m_row->m_timer_frequency, false);
+ if (m_row->m_routine != 0)
+ col_timer_frequency->store(m_row->m_timer_frequency, true);
+ else
+ col_timer_frequency->set_null();
break;
case 2:
DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
col_timer_resolution= (Field_longlong*) f;
- col_timer_resolution->store(m_row->m_timer_resolution, false);
+ if (m_row->m_routine != 0)
+ col_timer_resolution->store(m_row->m_timer_resolution, true);
+ else
+ col_timer_resolution->set_null();
break;
case 3:
DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
col_timer_overhead= (Field_longlong*) f;
- col_timer_overhead->store(m_row->m_timer_overhead, false);
+ if (m_row->m_routine != 0)
+ col_timer_overhead->store(m_row->m_timer_overhead, true);
+ else
+ col_timer_overhead->set_null();
break;
default:
DBUG_ASSERT(false);
=== modified file 'storage/perfschema/table_performance_timers.h'
--- a/storage/perfschema/table_performance_timers.h 2009-03-13 02:30:13 +0000
+++ b/storage/perfschema/table_performance_timers.h 2009-04-10 18:56:32 +0000
@@ -29,14 +29,16 @@
*/
struct row_performance_timers
{
+ /** ROUTINE, not displayed */
+ ulonglong m_routine;
/** Column TIMER_NAME. */
enum_timer_name m_timer_name;
/** Column TIMER_FREQUENCY. */
- longlong m_timer_frequency;
+ ulonglong m_timer_frequency;
/** Column TIMER_RESOLUTION. */
- longlong m_timer_resolution;
+ ulonglong m_timer_resolution;
/** Column TIMER_OVERHEAD. */
- longlong m_timer_overhead;
+ ulonglong m_timer_overhead;
};
/**
=== modified file 'unittest/mysys/my_rdtsc-t.c'
--- a/unittest/mysys/my_rdtsc-t.c 2008-11-07 01:41:07 +0000
+++ b/unittest/mysys/my_rdtsc-t.c 2009-04-10 18:56:32 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
+/* Copyright (C) 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
@@ -44,10 +44,10 @@
#define LOOP_COUNT 100
+MY_TIMER_INFO myt;
+
void test_init()
{
- MY_TIMER_INFO myt;
-
my_timer_init(&myt);
diag("----- Routine ---------------");
@@ -101,7 +101,11 @@ void test_cycle()
/* Expect at most 1 backward, the cycle value can overflow */
ok((backward <= 1), "The cycle timer is strictly increasing");
- ok((nonzero != 0), "The cycle timer is implemented");
+
+ if (myt.cycles_routine != 0)
+ ok((nonzero != 0), "The cycle timer is implemented");
+ else
+ ok((nonzero == LOOP_COUNT), "The cycle timer is not implemented and returns 0");
}
void test_nanosecond()
@@ -123,7 +127,11 @@ void test_nanosecond()
}
ok((backward == 0), "The nanosecond timer is increasing");
- ok((nonzero != 0), "The nanosecond timer is implemented");
+
+ if (myt.nanoseconds_routine != 0)
+ ok((nonzero != 0), "The nanosecond timer is implemented");
+ else
+ ok((nonzero == LOOP_COUNT), "The nanosecond timer is not implemented and returns 0");
}
void test_microsecond()
@@ -145,7 +153,11 @@ void test_microsecond()
}
ok((backward == 0), "The microsecond timer is increasing");
- ok((nonzero != 0), "The microsecond timer is implemented");
+
+ if (myt.microseconds_routine != 0)
+ ok((nonzero != 0), "The microsecond timer is implemented");
+ else
+ ok((nonzero == LOOP_COUNT), "The microsecond timer is not implemented and returns 0");
}
void test_millisecond()
@@ -167,7 +179,11 @@ void test_millisecond()
}
ok((backward == 0), "The millisecond timer is increasing");
- ok((nonzero != 0), "The millisecond timer is implemented");
+
+ if (myt.milliseconds_routine != 0)
+ ok((nonzero != 0), "The millisecond timer is implemented");
+ else
+ ok((nonzero == LOOP_COUNT), "The millisecond timer is not implemented and returns 0");
}
void test_tick()
@@ -189,7 +205,11 @@ void test_tick()
}
ok((backward == 0), "The tick timer is increasing");
- ok((nonzero != 0), "The tick timer is implemented");
+
+ if (myt.ticks_routine != 0)
+ ok((nonzero != 0), "The tick timer is implemented");
+ else
+ ok((nonzero == LOOP_COUNT), "The tick timer is not implemented and returns 0");
}
int main(int argc __attribute__((unused)),
| Thread |
|---|
| • bzr commit into mysql-6.0-perf branch (marc.alff:2860) Bug#44190 | Marc Alff | 10 Apr |