diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-06-19 12:17:07 +0300 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-06-19 12:17:07 +0300 |
commit | c378f71fd468664651d07462898baf5d391e9e3e (patch) | |
tree | d1baf62bfab420e9cf36b10240d695f8bd74e813 | |
parent | 2312be2979786365ee26ed5f85ce7a8a69fa0685 (diff) | |
download | mariadb-git-c378f71fd468664651d07462898baf5d391e9e3e.tar.gz |
Mtr profiling setup
A complete generated table fixture was added. Unfortunately, imported
tables behave bad in innodb. They are subject for checksumming on and on,
so it's better to ALTER TABLE FORCE them before actually profiling.
Usage:
Put vehicle_reg.ibd in mysq-test/std_data. (cant push it; too large)
./mtr --mem main.profile
It will emit notice, that you should rerun it with --start-dirty.
Wait ~two minutes.
Check that var/mysqld.1 directory is there. If not,
it was archived by mtr. Run:
mv var/log/main.profile-innodb/mysqld.1 var
Now rerun with the dirty dir:
./mtr main.profile --start-dirty --vardir=`pwd`/var --suite=main
You can add --gprof to collect the profiling data.
Make sure you've compiled mariadbd with -DWITH_GPROF=1.
Open gprof.msg and navigate to Call graph.
Dont use IDE to open! The file is huge. Vim/emacs is best, but maybe
sublime would work, too.
-rw-r--r-- | cmake/check_compiler_flag.cmake | 2 | ||||
-rwxr-xr-x | mysql-test/lib/v1/mysql-test-run.pl | 2 | ||||
-rw-r--r-- | mysql-test/main/profile.opt | 2 | ||||
-rw-r--r-- | mysql-test/main/profile.test | 67 | ||||
-rwxr-xr-x | mysql-test/mariadb-test-run.pl | 6 | ||||
-rw-r--r-- | mysql-test/std_data/vehicle_reg.cfg | bin | 0 -> 1511 bytes | |||
-rw-r--r-- | mysql-test/suite/plugins/suite.pm | 1 | ||||
-rw-r--r-- | mysys/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sql/records.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 |
10 files changed, 79 insertions, 9 deletions
diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake index 3c05c6bafd3..a03e0f89abb 100644 --- a/cmake/check_compiler_flag.cmake +++ b/cmake/check_compiler_flag.cmake @@ -25,7 +25,7 @@ MACRO (MY_CHECK_C_COMPILER_FLAG flag) ENDMACRO() MACRO (MY_CHECK_CXX_COMPILER_FLAG flag) - STRING(REGEX REPLACE "[-,= +]" "_" result "have_CXX_${flag}") + STRING(REGEX REPLACE "[-,=. +]" "_" result "have_CXX_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result} diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index aabe3d7521b..9982c449088 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -2766,7 +2766,7 @@ sub run_testcase ($) { # If --start-and-exit or --start-dirty given, stop here to let user manually # run tests # ---------------------------------------------------------------------- - if ( $opt_start_and_exit or $opt_start_dirty ) + if ( $opt_start_and_exit ) { mtr_timer_stop_all($glob_timers); mtr_report("\nServers started, exiting"); diff --git a/mysql-test/main/profile.opt b/mysql-test/main/profile.opt new file mode 100644 index 00000000000..da84f76d539 --- /dev/null +++ b/mysql-test/main/profile.opt @@ -0,0 +1,2 @@ +--innodb_buffer_pool_size=8M + diff --git a/mysql-test/main/profile.test b/mysql-test/main/profile.test new file mode 100644 index 00000000000..adc57afd755 --- /dev/null +++ b/mysql-test/main/profile.test @@ -0,0 +1,67 @@ +--source include/have_innodb.inc + +select @@innodb_buffer_pool_size; +--disable_query_log +--disable_result_log +# --source $MYSQL_TEST_DIR/std_data/cars.inc + +let no_vehicles = `select count(*)=0 from information_schema.tables where TABLE_NAME = 'vehicle_reg'`; +--if ($no_vehicles) { +--echo generating vehicle_reg from fixture, rerun with --start-dirty +CREATE TABLE vehicle_reg ( + _id int DEFAULT NULL, + RegistrationCategory varchar(64) DEFAULT NULL, + RegistrationTerm int DEFAULT NULL, + PurposeofUse varchar(64) DEFAULT NULL, + BodyShape varchar(64) DEFAULT NULL, + YearofManufacture int DEFAULT NULL, + Make varchar(64) DEFAULT NULL, + Model varchar(64) DEFAULT NULL, + Colour varchar(64) DEFAULT NULL, + FuelType varchar(64) DEFAULT NULL, + NumberofCylinders int DEFAULT NULL, + NumberofSeats int DEFAULT NULL, + ATMWeight varchar(64) DEFAULT NULL, + GCMWeight varchar(64) DEFAULT NULL, + GTMWeight varchar(64) DEFAULT NULL, + GVMWeight varchar(64) DEFAULT NULL, + TAREWeight varchar(64) DEFAULT NULL, + VINPrefix varchar(64) DEFAULT NULL +) engine=innodb; + +# vehicle_reg - Japan auto table, 765628 rows +let $MYSQLD_DATADIR= `select @@datadir`; +ALTER TABLE vehicle_reg DISCARD TABLESPACE; +--copy_file std_data/vehicle_reg.ibd $MYSQLD_DATADIR/test/vehicle_reg.ibd +--copy_file std_data/vehicle_reg.cfg $MYSQLD_DATADIR/test/vehicle_reg.cfg +ALTER TABLE vehicle_reg IMPORT TABLESPACE; +--let t1=`select UNIX_TIMESTAMP()` +ALTER TABLE vehicle_reg FORCE; +--let tdiff=`select UNIX_TIMESTAMP() - $t1` +--echo ALTER TABLE took $tdiff s +--} + +# Yeah, no "else", brothers +--if (!$no_vehicles) { +create temporary table counters_new_method ( + pk_value int, + counter int, + index (pk_value) +) engine=myisam; + + +--let $i= 5 +--echo i=$i +--let $method=bernoulli +--let percent=1 +--echo method=$method $percent% +--while($i) + eval + # INSERT INTO counters_new_method + SELECT _id, 0 FROM vehicle_reg tablesample $method($percent) + # ON DUPLICATE KEY UPDATE counter = counter + 1 + ; +--dec $i +--} +--} +--enable_query_log diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 148fd0fdee4..b4fa4a18d58 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -401,7 +401,7 @@ sub main { my $tests= collect_test_cases($opt_reorder, $opt_suites, \@opt_cases, \@opt_skip_test_list); mark_time_used('collect'); - mysql_install_db(default_mysqld(), "$opt_vardir/install.db") unless using_extern(); + mysql_install_db(default_mysqld(), "$opt_vardir/install.db") unless using_extern() or $opt_start_dirty; if ($opt_dry_run) { @@ -1560,7 +1560,7 @@ sub command_line_setup { # -------------------------------------------------------------------------- # Modified behavior with --start options # -------------------------------------------------------------------------- - if ($opt_start or $opt_start_dirty or $opt_start_exit) { + if ($opt_start or $opt_start_exit) { collect_option ('quick-collect', 1); $start_only= 1; } @@ -4879,7 +4879,7 @@ sub report_failure_and_restart ($) { } } - after_failure($tinfo); + after_failure($tinfo) unless $opt_start_dirty; mtr_report_test($tinfo); diff --git a/mysql-test/std_data/vehicle_reg.cfg b/mysql-test/std_data/vehicle_reg.cfg Binary files differnew file mode 100644 index 00000000000..4d3f5429597 --- /dev/null +++ b/mysql-test/std_data/vehicle_reg.cfg diff --git a/mysql-test/suite/plugins/suite.pm b/mysql-test/suite/plugins/suite.pm index 9f269fdcda0..d9fe6f03b42 100644 --- a/mysql-test/suite/plugins/suite.pm +++ b/mysql-test/suite/plugins/suite.pm @@ -6,6 +6,7 @@ use My::Platform; if (-d '../sql' && !&::using_extern()) { my $src = "$::bindir/plugin/auth_pam/auth_pam_tool"; + print("plugin".$::plugindir); my $dst = "$::plugindir/auth_pam_tool_dir/auth_pam_tool"; ::mkpath( "$::plugindir/auth_pam_tool_dir"); eval { symlink $src, $dst } or ::copy $src, $dst; diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 760c3c1475d..d156a7988bb 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -73,7 +73,7 @@ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|i386|i686") MY_CHECK_CXX_COMPILER_FLAG(-mpclmul) CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H) CHECK_INCLUDE_FILE(x86intrin.h HAVE_X86INTRIN_H) - IF(have_CXX__msse4.2 AND HAVE_CPUID_H) + IF(have_CXX__msse4_2 AND HAVE_CPUID_H) ADD_DEFINITIONS(-DHAVE_SSE42) IF (have_CXX__mpclmul AND HAVE_X86INTRIN_H) ADD_DEFINITIONS(-DHAVE_PCLMUL) diff --git a/sql/records.cc b/sql/records.cc index cdc4c170118..5b5c89f2a6d 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -326,7 +326,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, else if (table->tablesample_method) { - int method = table->tablesample_method->val_int(); + longlong method = table->tablesample_method->val_int(); double fract= (method % 100) / 100.0; info->sample_factor = fract; info->sample_counter= (ha_rows)(table->file->records() * fract + 0.5); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 35f4a30efd0..3a2588aa072 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3021,9 +3021,9 @@ static bool do_execute_sp(THD *thd, sp_head *sp) So just execute the statement. */ my_counter = 0; - sql_print_warning("Rejection count: %ull", my_counter); + sql_print_information("Rejection count: %ull", my_counter); int res= sp->execute_procedure(thd, &thd->lex->value_list); - sql_print_warning("Rejection count: %llu", my_counter); + sql_print_information("Rejection count: %llu", my_counter); thd->variables.select_limit= select_limit; thd->server_status&= ~bits_to_be_cleared; |