mirror of
https://github.com/MariaDB/server.git
synced 2025-04-01 21:05:34 +02:00
Merge 10.3 into 10.4
We omit the work-around commit 0b7fa5a05d
because it appears to be needed for CentOS 6 only,
which we no longer support.
This commit is contained in:
commit
b7b0bc8f11
14 changed files with 330 additions and 87 deletions
|
@ -2513,7 +2513,9 @@ static uint dump_routines_for_db(char *db)
|
||||||
|
|
||||||
char db_cl_name[MY_CS_NAME_SIZE];
|
char db_cl_name[MY_CS_NAME_SIZE];
|
||||||
int db_cl_altered= FALSE;
|
int db_cl_altered= FALSE;
|
||||||
|
// before 10.3 packages are not supported
|
||||||
|
uint upper_bound= mysql_get_server_version(mysql) >= 100300 ?
|
||||||
|
array_elements(routine_type) : 2;
|
||||||
DBUG_ENTER("dump_routines_for_db");
|
DBUG_ENTER("dump_routines_for_db");
|
||||||
DBUG_PRINT("enter", ("db: '%s'", db));
|
DBUG_PRINT("enter", ("db: '%s'", db));
|
||||||
|
|
||||||
|
@ -2543,7 +2545,7 @@ static uint dump_routines_for_db(char *db)
|
||||||
fputs("\t<routines>\n", sql_file);
|
fputs("\t<routines>\n", sql_file);
|
||||||
|
|
||||||
/* 0, retrieve and dump functions, 1, procedures, etc. */
|
/* 0, retrieve and dump functions, 1, procedures, etc. */
|
||||||
for (i= 0; i < array_elements(routine_type); i++)
|
for (i= 0; i < upper_bound; i++)
|
||||||
{
|
{
|
||||||
my_snprintf(query_buff, sizeof(query_buff),
|
my_snprintf(query_buff, sizeof(query_buff),
|
||||||
"SHOW %s STATUS WHERE Db = '%s'",
|
"SHOW %s STATUS WHERE Db = '%s'",
|
||||||
|
|
|
@ -186,8 +186,6 @@
|
||||||
#cmakedefine HAVE_POSIX_FALLOCATE 1
|
#cmakedefine HAVE_POSIX_FALLOCATE 1
|
||||||
#cmakedefine HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE 1
|
#cmakedefine HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE 1
|
||||||
#cmakedefine HAVE_PREAD 1
|
#cmakedefine HAVE_PREAD 1
|
||||||
#cmakedefine HAVE_PAUSE_INSTRUCTION 1
|
|
||||||
#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
|
|
||||||
#cmakedefine HAVE_RDTSCLL 1
|
#cmakedefine HAVE_RDTSCLL 1
|
||||||
#cmakedefine HAVE_READ_REAL_TIME 1
|
#cmakedefine HAVE_READ_REAL_TIME 1
|
||||||
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
|
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
|
||||||
|
|
|
@ -753,32 +753,6 @@ IF(NOT C_HAS_inline)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC)
|
|
||||||
STRING(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} processor)
|
|
||||||
IF(processor MATCHES "86" OR processor MATCHES "amd64" OR processor MATCHES "x64")
|
|
||||||
#Check for x86 PAUSE instruction
|
|
||||||
# We have to actually try running the test program, because of a bug
|
|
||||||
# in Solaris on x86_64, where it wrongly reports that PAUSE is not
|
|
||||||
# supported when trying to run an application. See
|
|
||||||
# http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6478684
|
|
||||||
CHECK_C_SOURCE_RUNS("
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
__asm__ __volatile__ (\"pause\");
|
|
||||||
return 0;
|
|
||||||
}" HAVE_PAUSE_INSTRUCTION)
|
|
||||||
ENDIF()
|
|
||||||
IF (NOT HAVE_PAUSE_INSTRUCTION)
|
|
||||||
CHECK_C_SOURCE_COMPILES("
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
__asm__ __volatile__ (\"rep; nop\");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
" HAVE_FAKE_PAUSE_INSTRUCTION)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
CHECK_SYMBOL_EXISTS(tcgetattr "termios.h" HAVE_TCGETATTR 1)
|
CHECK_SYMBOL_EXISTS(tcgetattr "termios.h" HAVE_TCGETATTR 1)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -46,10 +46,20 @@
|
||||||
#define HMT_high()
|
#define HMT_high()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __i386__ || defined __x86_64__ || defined _WIN32
|
||||||
|
# define HAVE_PAUSE_INSTRUCTION /* added in Intel Pentium 4 */
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void MY_RELAX_CPU(void)
|
static inline void MY_RELAX_CPU(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PAUSE_INSTRUCTION
|
#ifdef _WIN32
|
||||||
|
/*
|
||||||
|
In the Win32 API, the x86 PAUSE instruction is executed by calling
|
||||||
|
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
|
||||||
|
independent way by using YieldProcessor.
|
||||||
|
*/
|
||||||
|
YieldProcessor();
|
||||||
|
#elif defined HAVE_PAUSE_INSTRUCTION
|
||||||
/*
|
/*
|
||||||
According to the gcc info page, asm volatile means that the
|
According to the gcc info page, asm volatile means that the
|
||||||
instruction has important side-effects and must not be removed.
|
instruction has important side-effects and must not be removed.
|
||||||
|
@ -61,16 +71,6 @@ static inline void MY_RELAX_CPU(void)
|
||||||
#else
|
#else
|
||||||
__asm__ __volatile__ ("pause");
|
__asm__ __volatile__ ("pause");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(HAVE_FAKE_PAUSE_INSTRUCTION)
|
|
||||||
__asm__ __volatile__ ("rep; nop");
|
|
||||||
#elif defined _WIN32
|
|
||||||
/*
|
|
||||||
In the Win32 API, the x86 PAUSE instruction is executed by calling
|
|
||||||
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
|
|
||||||
independent way by using YieldProcessor.
|
|
||||||
*/
|
|
||||||
YieldProcessor();
|
|
||||||
#elif defined(_ARCH_PWR8)
|
#elif defined(_ARCH_PWR8)
|
||||||
__ppc_get_timebase();
|
__ppc_get_timebase();
|
||||||
#else
|
#else
|
||||||
|
@ -81,6 +81,20 @@ static inline void MY_RELAX_CPU(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_PAUSE_INSTRUCTION
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
extern unsigned my_cpu_relax_multiplier;
|
||||||
|
void my_cpu_init(void);
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define my_cpu_relax_multiplier 200
|
||||||
|
# define my_cpu_init() /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LF_BACKOFF should be used to improve performance on hyperthreaded CPUs. Intel
|
LF_BACKOFF should be used to improve performance on hyperthreaded CPUs. Intel
|
||||||
recommends to use it in spin loops also on non-HT machines to reduce power
|
recommends to use it in spin loops also on non-HT machines to reduce power
|
||||||
|
@ -94,9 +108,23 @@ static inline void MY_RELAX_CPU(void)
|
||||||
|
|
||||||
static inline int LF_BACKOFF(void)
|
static inline int LF_BACKOFF(void)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned i= my_cpu_relax_multiplier;
|
||||||
for (i= 0; i < 200; i++)
|
while (i--)
|
||||||
MY_RELAX_CPU();
|
MY_RELAX_CPU();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run a delay loop while waiting for a shared resource to be released.
|
||||||
|
@param delay originally, roughly microseconds on 100 MHz Intel Pentium
|
||||||
|
*/
|
||||||
|
static inline void ut_delay(unsigned delay)
|
||||||
|
{
|
||||||
|
unsigned i= my_cpu_relax_multiplier / 4 * delay;
|
||||||
|
HMT_low();
|
||||||
|
while (i--)
|
||||||
|
MY_RELAX_CPU();
|
||||||
|
HMT_medium();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
1
mysql-test/main/mysqldump-compat-102.opt
Normal file
1
mysql-test/main/mysqldump-compat-102.opt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
-V10.2.1-MariaDB
|
110
mysql-test/main/mysqldump-compat-102.result
Normal file
110
mysql-test/main/mysqldump-compat-102.result
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
#
|
||||||
|
# MDEV-17429 mysqldump uses 10.3 options with pre-10.3 servers and breaks
|
||||||
|
#
|
||||||
|
SELECT @@version;
|
||||||
|
@@version
|
||||||
|
10.2.1-MariaDB
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
CREATE DATABASE db1_mdev17429;
|
||||||
|
USE db1_mdev17429;
|
||||||
|
CREATE PROCEDURE p1(a INT)
|
||||||
|
AS BEGIN
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
CREATE OR REPLACE PACKAGE employee_tools AS
|
||||||
|
FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2);
|
||||||
|
PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2));
|
||||||
|
PROCEDURE raiseSalaryStd(eid INT);
|
||||||
|
PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2));
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
CREATE PACKAGE BODY employee_tools AS
|
||||||
|
-- package body variables
|
||||||
|
stdRaiseAmount DECIMAL(10,2):=500;
|
||||||
|
-- private routines
|
||||||
|
PROCEDURE log (eid INT, ecmnt TEXT) AS
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO employee_log (id, cmnt) VALUES (eid, ecmnt);
|
||||||
|
END;
|
||||||
|
-- public routines
|
||||||
|
PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2)) AS
|
||||||
|
eid INT;
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO employee (name, salary) VALUES (ename, esalary);
|
||||||
|
eid:= last_insert_id();
|
||||||
|
log(eid, 'hire ' || ename);
|
||||||
|
END;
|
||||||
|
FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2) AS
|
||||||
|
nSalary DECIMAL(10,2);
|
||||||
|
BEGIN
|
||||||
|
SELECT salary INTO nSalary FROM employee WHERE id=eid;
|
||||||
|
log(eid, 'getSalary id=' || eid || ' salary=' || nSalary);
|
||||||
|
RETURN nSalary;
|
||||||
|
END;
|
||||||
|
PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2)) AS
|
||||||
|
BEGIN
|
||||||
|
UPDATE employee SET salary=salary+amount WHERE id=eid;
|
||||||
|
log(eid, 'raiseSalary id=' || eid || ' amount=' || amount);
|
||||||
|
END;
|
||||||
|
PROCEDURE raiseSalaryStd(eid INT) AS
|
||||||
|
BEGIN
|
||||||
|
raiseSalary(eid, stdRaiseAmount);
|
||||||
|
log(eid, 'raiseSalaryStd id=' || eid);
|
||||||
|
END;
|
||||||
|
BEGIN
|
||||||
|
-- This code is executed when the current session
|
||||||
|
-- accesses any of the package routines for the first time
|
||||||
|
log(0, 'Session ' || connection_id() || ' ' || current_user || ' started');
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
-- MariaDB dump DUMPVERSION Distrib DISTVERSION, for OS
|
||||||
|
--
|
||||||
|
-- Host: localhost Database: db1_mdev17429
|
||||||
|
-- ------------------------------------------------------
|
||||||
|
-- Server version 10.2.1-MariaDB
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8mb4 */;
|
||||||
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||||
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||||
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping routines for database 'db1_mdev17429'
|
||||||
|
--
|
||||||
|
/*!50003 DROP PROCEDURE IF EXISTS `p1` */;
|
||||||
|
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||||
|
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||||
|
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||||
|
/*!50003 SET character_set_client = latin1 */ ;
|
||||||
|
/*!50003 SET character_set_results = latin1 */ ;
|
||||||
|
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
|
||||||
|
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||||
|
/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ;
|
||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER="root"@"localhost" PROCEDURE "p1"(a INT)
|
||||||
|
AS BEGIN
|
||||||
|
NULL;
|
||||||
|
END ;;
|
||||||
|
DELIMITER ;
|
||||||
|
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||||
|
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||||
|
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||||
|
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||||
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||||
|
|
||||||
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
|
-- Dump completed on TIMESTAMP
|
||||||
|
DROP DATABASE db1_mdev17429;
|
||||||
|
SET sql_mode=DEFAULT;
|
83
mysql-test/main/mysqldump-compat-102.test
Normal file
83
mysql-test/main/mysqldump-compat-102.test
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
# Embedded server doesn't support external clients
|
||||||
|
--source include/not_embedded.inc
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-17429 mysqldump uses 10.3 options with pre-10.3 servers and breaks
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
# Make sure the server reports itself as 10.2.1-MariaDB
|
||||||
|
SELECT @@version;
|
||||||
|
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
CREATE DATABASE db1_mdev17429;
|
||||||
|
USE db1_mdev17429;
|
||||||
|
|
||||||
|
DELIMITER $$;
|
||||||
|
|
||||||
|
CREATE PROCEDURE p1(a INT)
|
||||||
|
AS BEGIN
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
|
||||||
|
CREATE OR REPLACE PACKAGE employee_tools AS
|
||||||
|
FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2);
|
||||||
|
PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2));
|
||||||
|
PROCEDURE raiseSalaryStd(eid INT);
|
||||||
|
PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2));
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
CREATE PACKAGE BODY employee_tools AS
|
||||||
|
-- package body variables
|
||||||
|
stdRaiseAmount DECIMAL(10,2):=500;
|
||||||
|
|
||||||
|
-- private routines
|
||||||
|
PROCEDURE log (eid INT, ecmnt TEXT) AS
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO employee_log (id, cmnt) VALUES (eid, ecmnt);
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- public routines
|
||||||
|
PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2)) AS
|
||||||
|
eid INT;
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO employee (name, salary) VALUES (ename, esalary);
|
||||||
|
eid:= last_insert_id();
|
||||||
|
log(eid, 'hire ' || ename);
|
||||||
|
END;
|
||||||
|
|
||||||
|
FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2) AS
|
||||||
|
nSalary DECIMAL(10,2);
|
||||||
|
BEGIN
|
||||||
|
SELECT salary INTO nSalary FROM employee WHERE id=eid;
|
||||||
|
log(eid, 'getSalary id=' || eid || ' salary=' || nSalary);
|
||||||
|
RETURN nSalary;
|
||||||
|
END;
|
||||||
|
|
||||||
|
PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2)) AS
|
||||||
|
BEGIN
|
||||||
|
UPDATE employee SET salary=salary+amount WHERE id=eid;
|
||||||
|
log(eid, 'raiseSalary id=' || eid || ' amount=' || amount);
|
||||||
|
END;
|
||||||
|
|
||||||
|
PROCEDURE raiseSalaryStd(eid INT) AS
|
||||||
|
BEGIN
|
||||||
|
raiseSalary(eid, stdRaiseAmount);
|
||||||
|
log(eid, 'raiseSalaryStd id=' || eid);
|
||||||
|
END;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
-- This code is executed when the current session
|
||||||
|
-- accesses any of the package routines for the first time
|
||||||
|
log(0, 'Session ' || connection_id() || ' ' || current_user || ' started');
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
DELIMITER ;$$
|
||||||
|
|
||||||
|
# mysqldump output is expected to have standalone PROCEDURE/FUNCTION, but not PACKAGE/PACKAGE BODY.
|
||||||
|
|
||||||
|
--replace_regex /-- MariaDB dump.*[^\n]/-- MariaDB dump DUMPVERSION Distrib DISTVERSION, for OS/ / on [0-9 :-]+/ on TIMESTAMP/
|
||||||
|
--exec $MYSQL_DUMP --quick --routines --triggers --no-create-info --skip-lock-tables --no-data --compress -uroot db1_mdev17429
|
||||||
|
|
||||||
|
DROP DATABASE db1_mdev17429;
|
||||||
|
SET sql_mode=DEFAULT;
|
|
@ -44,7 +44,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c my_default.c
|
||||||
my_getncpus.c my_safehash.c my_chmod.c my_rnd.c
|
my_getncpus.c my_safehash.c my_chmod.c my_rnd.c
|
||||||
my_uuid.c wqueue.c waiting_threads.c ma_dyncol.c ../sql-common/my_time.c
|
my_uuid.c wqueue.c waiting_threads.c ma_dyncol.c ../sql-common/my_time.c
|
||||||
my_rdtsc.c my_context.c psi_noop.c
|
my_rdtsc.c my_context.c psi_noop.c
|
||||||
my_atomic_writes.c my_likely.c
|
my_atomic_writes.c my_cpu.c my_likely.c
|
||||||
file_logger.c my_dlerror.c)
|
file_logger.c my_dlerror.c)
|
||||||
|
|
||||||
IF (WIN32)
|
IF (WIN32)
|
||||||
|
|
82
mysys/my_cpu.c
Normal file
82
mysys/my_cpu.c
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/* Copyright (c) 2019, MariaDB Corporation.
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
|
#include <my_global.h>
|
||||||
|
#include <my_atomic.h>
|
||||||
|
#include <my_cpu.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_PAUSE_INSTRUCTION
|
||||||
|
/** How many times to invoke PAUSE in a loop */
|
||||||
|
unsigned my_cpu_relax_multiplier = 200;
|
||||||
|
|
||||||
|
# include <stdint.h>
|
||||||
|
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# include <intrin.h>
|
||||||
|
# else
|
||||||
|
# include <x86intrin.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#define PAUSE4 MY_RELAX_CPU(); MY_RELAX_CPU(); MY_RELAX_CPU(); MY_RELAX_CPU()
|
||||||
|
#define PAUSE16 PAUSE4; PAUSE4; PAUSE4; PAUSE4
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize my_cpu_relax_multiplier.
|
||||||
|
|
||||||
|
Determine the duration of a PAUSE instruction by running an
|
||||||
|
unrolled loop of 16 PAUSE instructions twice, and taking the
|
||||||
|
faster of the two runs. In this way, even if the execution is
|
||||||
|
interrupted by the operating system, it should be extremely
|
||||||
|
unlikely that both loops get interrupted.
|
||||||
|
|
||||||
|
On the Intel Skylake microarchitecture, the PAUSE instruction takes
|
||||||
|
around 140 clock cycles, while on earlier microarchitectures it could
|
||||||
|
be 10 clock cycles or less. Scale the PAUSE loop counter accordingly.
|
||||||
|
|
||||||
|
On a pre-Skylake Intel Xeon CPU E5-2630 v4 @ 2.20GHz running an AMD64
|
||||||
|
executable, the numbers would be between 172 and 220 when all the code
|
||||||
|
is inlined as follows:
|
||||||
|
|
||||||
|
rdtsc,mov,shl,or, 16*pause,
|
||||||
|
rdtsc,mov,shl,or, 16*pause,
|
||||||
|
rdtsc.
|
||||||
|
|
||||||
|
That would yield 11 to 14 cycles per PAUSE instruction even if we
|
||||||
|
(wrongly) ignore the overhead of the other instructions.
|
||||||
|
|
||||||
|
On a Skylake mobile processor Intel Core i7-6500U CPU @ 2.50GHz, the
|
||||||
|
numbers would range from 1896 to 2410 (or 1976 if taking the minimum
|
||||||
|
of two runs), yielding 118 to 151 (or 123) cycles per PAUSE instruction.
|
||||||
|
|
||||||
|
Let us define a threshold at roughly 30 cycles per PAUSE instruction,
|
||||||
|
and use a shorter delay if the PAUSE instruction takes longer than
|
||||||
|
that. In some AMD processors, the PAUSE instruction could take 40 or
|
||||||
|
50 cycles. Let us use a shorter delay multiplier for them as well.
|
||||||
|
|
||||||
|
The 1/10 scaling factor (200/20) was derived experimentally by
|
||||||
|
Mikhail Sinyavin from Intel.
|
||||||
|
*/
|
||||||
|
void my_cpu_init(void)
|
||||||
|
{
|
||||||
|
uint64_t t0, t1, t2;
|
||||||
|
t0= __rdtsc();
|
||||||
|
PAUSE16;
|
||||||
|
t1= __rdtsc();
|
||||||
|
PAUSE16;
|
||||||
|
t2= __rdtsc();
|
||||||
|
if (t2 - t1 > 30 * 16 && t1 - t0 > 30 * 16)
|
||||||
|
my_cpu_relax_multiplier= 20;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -4891,6 +4891,7 @@ static int init_server_components()
|
||||||
We need to call each of these following functions to ensure that
|
We need to call each of these following functions to ensure that
|
||||||
all things are initialized so that unireg_abort() doesn't fail
|
all things are initialized so that unireg_abort() doesn't fail
|
||||||
*/
|
*/
|
||||||
|
my_cpu_init();
|
||||||
mdl_init();
|
mdl_init();
|
||||||
if (tdc_init() || hostname_cache_init())
|
if (tdc_init() || hostname_cache_init())
|
||||||
unireg_abort(1);
|
unireg_abort(1);
|
||||||
|
|
|
@ -211,7 +211,7 @@ public:
|
||||||
{
|
{
|
||||||
my_socket socket_id= slave->sock_fd();
|
my_socket socket_id= slave->sock_fd();
|
||||||
m_max_fd= (socket_id > m_max_fd ? socket_id : m_max_fd);
|
m_max_fd= (socket_id > m_max_fd ? socket_id : m_max_fd);
|
||||||
#ifndef WINDOWS
|
#ifndef _WIN32
|
||||||
if (socket_id > FD_SETSIZE)
|
if (socket_id > FD_SETSIZE)
|
||||||
{
|
{
|
||||||
sql_print_error("Semisync slave socket fd is %u. "
|
sql_print_error("Semisync slave socket fd is %u. "
|
||||||
|
@ -219,7 +219,7 @@ public:
|
||||||
"greater than %u (FD_SETSIZE).", socket_id, FD_SETSIZE);
|
"greater than %u (FD_SETSIZE).", socket_id, FD_SETSIZE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif //WINDOWS
|
#endif //_WIN32
|
||||||
FD_SET(socket_id, &m_init_fds);
|
FD_SET(socket_id, &m_init_fds);
|
||||||
fds_index++;
|
fds_index++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
|
Copyright (c) 2017, 2019, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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 the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -29,8 +29,8 @@ Created 2013-03-26 Sunny Bains.
|
||||||
#ifndef ib0mutex_h
|
#ifndef ib0mutex_h
|
||||||
#define ib0mutex_h
|
#define ib0mutex_h
|
||||||
|
|
||||||
#include "ut0ut.h"
|
#include "my_atomic.h"
|
||||||
#include "ut0rnd.h"
|
#include "my_cpu.h"
|
||||||
#include "os0event.h"
|
#include "os0event.h"
|
||||||
#include "sync0arr.h"
|
#include "sync0arr.h"
|
||||||
|
|
||||||
|
|
|
@ -53,14 +53,6 @@ Created 1/20/1994 Heikki Tuuri
|
||||||
/** Time stamp */
|
/** Time stamp */
|
||||||
typedef time_t ib_time_t;
|
typedef time_t ib_time_t;
|
||||||
|
|
||||||
#if defined (__GNUC__)
|
|
||||||
# define UT_COMPILER_BARRIER() __asm__ __volatile__ ("":::"memory")
|
|
||||||
#elif defined (_MSC_VER)
|
|
||||||
# define UT_COMPILER_BARRIER() _ReadWriteBarrier()
|
|
||||||
#else
|
|
||||||
# define UT_COMPILER_BARRIER()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*********************************************************************//**
|
/*********************************************************************//**
|
||||||
Delays execution for at most max_wait_us microseconds or returns earlier
|
Delays execution for at most max_wait_us microseconds or returns earlier
|
||||||
if cond becomes true.
|
if cond becomes true.
|
||||||
|
@ -269,14 +261,7 @@ void
|
||||||
ut_sprintf_timestamp(
|
ut_sprintf_timestamp(
|
||||||
/*=================*/
|
/*=================*/
|
||||||
char* buf); /*!< in: buffer where to sprintf */
|
char* buf); /*!< in: buffer where to sprintf */
|
||||||
/*************************************************************//**
|
|
||||||
Runs an idle loop on CPU. The argument gives the desired delay
|
|
||||||
in microseconds on 100 MHz Pentium + Visual C++.
|
|
||||||
@return dummy value */
|
|
||||||
void
|
|
||||||
ut_delay(
|
|
||||||
/*=====*/
|
|
||||||
ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */
|
|
||||||
/*************************************************************//**
|
/*************************************************************//**
|
||||||
Prints the contents of a memory buffer in hex and ascii. */
|
Prints the contents of a memory buffer in hex and ascii. */
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2017, MariaDB Corporation.
|
Copyright (c) 2017, 2019, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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 the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -283,27 +283,6 @@ ut_sprintf_timestamp(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************//**
|
|
||||||
Runs an idle loop on CPU. The argument gives the desired delay
|
|
||||||
in microseconds on 100 MHz Pentium + Visual C++.
|
|
||||||
@return dummy value */
|
|
||||||
void
|
|
||||||
ut_delay(
|
|
||||||
/*=====*/
|
|
||||||
ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */
|
|
||||||
{
|
|
||||||
ulint i;
|
|
||||||
|
|
||||||
HMT_low();
|
|
||||||
|
|
||||||
for (i = 0; i < delay * 50; i++) {
|
|
||||||
MY_RELAX_CPU();
|
|
||||||
UT_COMPILER_BARRIER();
|
|
||||||
}
|
|
||||||
|
|
||||||
HMT_medium();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************//**
|
/*************************************************************//**
|
||||||
Prints the contents of a memory buffer in hex and ascii. */
|
Prints the contents of a memory buffer in hex and ascii. */
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue