Skip to content

Commit bfa79bd

Browse files
AliSQLAliSQL
authored andcommitted
[Feature] Issue#55 Support CPU_TIME metrics
Supply CPU_time metric to help analysis.
1 parent 9d1a800 commit bfa79bd

15 files changed

Lines changed: 120 additions & 34 deletions

config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
220220
#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
221221
#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1
222+
#cmakedefine HAVE_PTHREAD_GETCPUCLOCKID 1
222223
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
223224
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
224225
#cmakedefine HAVE_PTHREAD_KILL 1

configure.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE)
553553
CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
554554
CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
555555
CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK)
556+
CHECK_FUNCTION_EXISTS (pthread_getcpuclockid HAVE_PTHREAD_GETCPUCLOCKID)
556557
CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
557558
CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
558559
CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)

include/my_pthread.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,23 @@ extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
318318
void *my_pthread_getspecific_imp(pthread_key_t key);
319319
#endif
320320

321+
/* CPU time */
322+
#if defined(HAVE_PTHREAD_GETCPUCLOCKID) && defined(HAVE_CLOCK_GETTIME)
323+
324+
#define HAVE_CPU_TIME
325+
#define my_pthread_getcpuclockid(A) pthread_getcpuclockid(pthread_self(), A)
326+
#define my_clock_gettime(A, B) clock_gettime(A, B)
327+
typedef clockid_t my_pthread_clock_id;
328+
329+
#else /* Not support on other platform */
330+
331+
#define my_pthread_getcpuclockid(A) (-1)
332+
#define my_clock_gettime(A, B) (-1)
333+
typedef ulonglong my_pthread_clock_id;
334+
335+
#endif /* CPU time */
336+
337+
321338
#ifndef HAVE_LOCALTIME_R
322339
struct tm *localtime_r(const time_t *clock, struct tm *res);
323340
#endif
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
show status like 'cpu_time';
2+
Variable_name Value
3+
CPU_time #
4+
create table t(id int);
5+
drop table t;
6+
show status like 'cpu_time';
7+
Variable_name Value
8+
CPU_time #
9+
show full processlist;
10+
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read CPU_time
11+
# root localhost test Query xxx # # # # # # # #

mysql-test/r/thread_memory_usage.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ select * from test.t1;
44
id
55
1
66
show full processlist;
7-
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read
8-
# root localhost test # xxx # # # # # # #
9-
# root localhost test # xxx # # # # # # #
7+
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read CPU_time
8+
# root localhost test # xxx # # # # # # # #
9+
# root localhost test # xxx # # # # # # # #
1010
drop table test.t1;

mysql-test/suite/funcs_1/datadict/processlist_val.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ echo
9696
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
9797
--sorted_result
9898
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
99-
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 #
99+
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 # 14 #
100100
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
101101
--sorted_result
102102
SHOW FULL PROCESSLIST;
@@ -173,7 +173,7 @@ let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
173173
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
174174
--sorted_result
175175
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
176-
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 #
176+
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 # 14 #
177177
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
178178
--sorted_result
179179
SHOW FULL PROCESSLIST;
@@ -222,7 +222,7 @@ connection con1;
222222
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
223223
--sorted_result
224224
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
225-
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 #
225+
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 # 14 #
226226
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
227227
--sorted_result
228228
SHOW FULL PROCESSLIST;
@@ -260,7 +260,7 @@ connection con2;
260260
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
261261
--sorted_result
262262
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
263-
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 #
263+
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 # 14 #
264264
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
265265
--sorted_result
266266
SHOW FULL PROCESSLIST;
@@ -324,7 +324,7 @@ WHERE ID = @test_user_con2_id AND Command IN('Query','Execute')
324324
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
325325
--sorted_result
326326
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
327-
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 #
327+
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 # 10 # 11 # 12 # 13 # 14 #
328328
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
329329
--sorted_result
330330
SHOW FULL PROCESSLIST;
@@ -460,7 +460,7 @@ echo
460460
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
461461
--sorted_result
462462
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
463-
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 # 10 # 11 # 12 # 13 #
463+
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 # 10 # 11 # 12 # 13 # 14 #
464464
--replace_result "init" STATE "starting" STATE "cleaning up" STATE
465465
--sorted_result
466466
SHOW FULL PROCESSLIST;

mysql-test/suite/funcs_1/r/processlist_val_ps.result

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

mysql-test/suite/rds/r/feature_checksum_restrict_io_issue25.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ key(col2)
77
)engine= innodb;
88
Table Checksum
99
test_1.t1 1724218332
10-
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read
11-
# root localhost test Sleep xxx # # # # # # #
12-
# root localhost test Query xxx # # # # # # #
13-
# root localhost test Sleep xxx # # # # # # #
10+
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read CPU_time
11+
# root localhost test Sleep xxx # # # # # # # #
12+
# root localhost test Query xxx # # # # # # # #
13+
# root localhost test Sleep xxx # # # # # # # #

mysql-test/suite/rds/r/feature_restrict_iops_issue25.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ checksum table test_1.t1;
1010
Table Checksum
1111
test_1.t1 3791299187
1212
show full processlist;
13-
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read
14-
# root localhost test Query xxx # # # # # # #
13+
Id User Host db Command Time State Info Memory_used Memory_used_by_query Logical_read Physical_sync_read Physical_async_read CPU_time
14+
# root localhost test Query xxx # # # # # # # #
1515
show status like '%IO_limit_count%';
1616
Variable_name Value
1717
IO_limit_count #

mysql-test/suite/rds/t/feature_checksum_restrict_io_issue25.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ commit;
2424
set session rds_sql_max_iops=2;
2525
checksum table test_1.t1;
2626

27-
--replace_column 1 # 6 xxx 7 # 8 # 9 # 10 # 11 # 12 # 13 #
27+
--replace_column 1 # 6 xxx 7 # 8 # 9 # 10 # 11 # 12 # 13 # 14 #
2828
show full processlist;
2929

3030

0 commit comments

Comments
 (0)