mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
042fc29597
Starting with the Intel Skylake microarchitecture, the PAUSE instruction latency is about 140 clock cycles instead of earlier 10. On AMD processors, the latency could be 10 or 50 clock cycles, depending on microarchitecture. Because of this big range of latency, let us scale the loops around the PAUSE instruction based on timing results at server startup. my_cpu_relax_multiplier: New variable: How many times to invoke PAUSE in a loop. Only defined for IA-32 and AMD64. my_cpu_init(): Determine with RDTSC the time to run 16 PAUSE instructions in two unrolled loops according, and based on the quicker of the two runs, initialize my_cpu_relax_multiplier. This form of calibration was suggested by Mikhail Sinyavin from Intel. LF_BACKOFF(), ut_delay(): Use my_cpu_relax_multiplier when available. ut_delay(): Define inline in my_cpu.h. UT_COMPILER_BARRIER(): Remove. This does not seem to have any effect, because in our ut_delay() implementation, no computations are being performed inside the loop. The purpose of UT_COMPILER_BARRIER() was to prohibit the compiler from reordering computations. It was not emitting any code.
108 lines
4.2 KiB
CMake
108 lines
4.2 KiB
CMake
# Copyright (c) 2006, 2014, Oracle and/or its affiliates
|
|
# Copyright (c) 2009, 2018, 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-1335 USA
|
|
|
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
|
|
|
|
SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c my_default.c
|
|
get_password.c
|
|
errors.c hash.c list.c
|
|
mf_cache.c mf_dirname.c mf_fn_ext.c
|
|
mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c
|
|
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
|
|
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c
|
|
mf_tempfile.c mf_unixpath.c mf_wcomp.c mulalloc.c my_access.c
|
|
my_alloc.c my_bit.c my_bitmap.c my_chsize.c
|
|
my_compress.c my_copy.c my_create.c my_delete.c
|
|
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c
|
|
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_compare.c my_init.c
|
|
my_lib.c my_lock.c my_malloc.c my_mess.c
|
|
my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c
|
|
my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c
|
|
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
|
|
my_basename.c
|
|
my_write.c ptr_cmp.c queues.c stacktrace.c
|
|
string.c thr_alarm.c thr_lock.c thr_mutex.c
|
|
thr_rwlock.c thr_timer.c
|
|
tree.c typelib.c base64.c my_memmem.c
|
|
my_getpagesize.c
|
|
guess_malloc_library.c
|
|
lf_alloc-pin.c lf_dynarray.c lf_hash.c
|
|
safemalloc.c my_new.cc
|
|
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_rdtsc.c my_context.c psi_noop.c
|
|
my_atomic_writes.c my_cpu.c my_likely.c
|
|
file_logger.c my_dlerror.c)
|
|
|
|
IF (WIN32)
|
|
SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c)
|
|
ENDIF()
|
|
|
|
IF(UNIX)
|
|
SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_addr_resolve.c my_setuser.c)
|
|
ENDIF()
|
|
|
|
IF(HAVE_ALARM)
|
|
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_alarm.c)
|
|
ENDIF()
|
|
|
|
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_C_COMPILER_ID MATCHES "SunPro")
|
|
# Inline assembly template for rdtsc
|
|
SET_SOURCE_FILES_PROPERTIES(my_rdtsc.c
|
|
PROPERTIES COMPILE_FLAGS "${CMAKE_CURRENT_SOURCE_DIR}/my_timer_cycles.il")
|
|
ENDIF()
|
|
|
|
IF(HAVE_LINUX_LARGE_PAGES)
|
|
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_largepage.c)
|
|
ENDIF()
|
|
|
|
IF(HAVE_MLOCK)
|
|
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_lockmem.c)
|
|
ENDIF()
|
|
|
|
ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
|
|
TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY}
|
|
${LIBNSL} ${LIBM} ${LIBRT} ${LIBDL} ${LIBSOCKET} ${LIBEXECINFO} ${CRC32_LIBRARY})
|
|
DTRACE_INSTRUMENT(mysys)
|
|
|
|
IF(HAVE_BFD_H)
|
|
TARGET_LINK_LIBRARIES(mysys bfd)
|
|
ENDIF(HAVE_BFD_H)
|
|
|
|
IF (WIN32)
|
|
TARGET_LINK_LIBRARIES(mysys IPHLPAPI)
|
|
ENDIF(WIN32)
|
|
|
|
# Need explicit pthread for gcc -fsanitize=address
|
|
IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
|
|
TARGET_LINK_LIBRARIES(mysys pthread)
|
|
ENDIF()
|
|
|
|
ADD_EXECUTABLE(thr_lock thr_lock.c)
|
|
TARGET_LINK_LIBRARIES(thr_lock mysys)
|
|
SET_TARGET_PROPERTIES(thr_lock PROPERTIES COMPILE_FLAGS "-DMAIN")
|
|
|
|
ADD_EXECUTABLE(thr_timer thr_timer.c)
|
|
TARGET_LINK_LIBRARIES(thr_timer mysys)
|
|
SET_TARGET_PROPERTIES(thr_timer PROPERTIES COMPILE_FLAGS "-DMAIN")
|
|
|
|
ADD_EXECUTABLE(test_hash hash.c)
|
|
TARGET_LINK_LIBRARIES(test_hash mysys)
|
|
SET_TARGET_PROPERTIES(test_hash PROPERTIES COMPILE_FLAGS "-DMAIN")
|
|
|
|
IF(MSVC)
|
|
INSTALL_DEBUG_TARGET(mysys DESTINATION ${INSTALL_LIBDIR}/debug)
|
|
ENDIF()
|