You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
7.4 KiB

Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled Essentially, the problem is that safemalloc is excruciatingly slow as it checks all allocated blocks for overrun at each memory management primitive, yielding a almost exponential slowdown for the memory management functions (malloc, realloc, free). The overrun check basically consists of verifying some bytes of a block for certain magic keys, which catches some simple forms of overrun. Another minor problem is violation of aliasing rules and that its own internal list of blocks is prone to corruption. Another issue with safemalloc is rather the maintenance cost as the tool has a significant impact on the server code. Given the magnitude of memory debuggers available nowadays, especially those that are provided with the platform malloc implementation, maintenance of a in-house and largely obsolete memory debugger becomes a burden that is not worth the effort due to its slowness and lack of support for detecting more common forms of heap corruption. Since there are third-party tools that can provide the same functionality at a lower or comparable performance cost, the solution is to simply remove safemalloc. Third-party tools can provide the same functionality at a lower or comparable performance cost. The removal of safemalloc also allows a simplification of the malloc wrappers, removing quite a bit of kludge: redefinition of my_malloc, my_free and the removal of the unused second argument of my_free. Since free() always check whether the supplied pointer is null, redudant checks are also removed. Also, this patch adds unit testing for my_malloc and moves my_realloc implementation into the same file as the other memory allocation primitives.
16 years ago
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled Essentially, the problem is that safemalloc is excruciatingly slow as it checks all allocated blocks for overrun at each memory management primitive, yielding a almost exponential slowdown for the memory management functions (malloc, realloc, free). The overrun check basically consists of verifying some bytes of a block for certain magic keys, which catches some simple forms of overrun. Another minor problem is violation of aliasing rules and that its own internal list of blocks is prone to corruption. Another issue with safemalloc is rather the maintenance cost as the tool has a significant impact on the server code. Given the magnitude of memory debuggers available nowadays, especially those that are provided with the platform malloc implementation, maintenance of a in-house and largely obsolete memory debugger becomes a burden that is not worth the effort due to its slowness and lack of support for detecting more common forms of heap corruption. Since there are third-party tools that can provide the same functionality at a lower or comparable performance cost, the solution is to simply remove safemalloc. Third-party tools can provide the same functionality at a lower or comparable performance cost. The removal of safemalloc also allows a simplification of the malloc wrappers, removing quite a bit of kludge: redefinition of my_malloc, my_free and the removal of the unused second argument of my_free. Since free() always check whether the supplied pointer is null, redudant checks are also removed. Also, this patch adds unit testing for my_malloc and moves my_realloc implementation into the same file as the other memory allocation primitives.
16 years ago
19 years ago
  1. #!/bin/sh
  2. # Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public
  6. # License as published by the Free Software Foundation; version 2
  7. # of the License.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Library General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with this library; if not, write to the Free
  16. # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  17. # MA 02111-1307, USA
  18. ########################################################################
  19. get_key_value()
  20. {
  21. echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  22. }
  23. usage()
  24. {
  25. cat <<EOF
  26. Usage: $0 [-h|-n] [configure-options]
  27. -h, --help Show this help message.
  28. -n, --just-print Don't actually run any commands; just print them.
  29. -c, --just-configure Stop after running configure.
  30. --with-debug=full Build with full debug(no optimizations, keep call stack).
  31. --warning-mode=[old|pedantic|maintainer]
  32. Influences the debug flags. Old is default.
  33. --prefix=path Build with prefix 'path'.
  34. Note: this script is intended for internal use by MySQL developers.
  35. EOF
  36. }
  37. parse_options()
  38. {
  39. while test $# -gt 0
  40. do
  41. case "$1" in
  42. --prefix=*)
  43. prefix=`get_key_value "$1"`;;
  44. --with-debug=full)
  45. full_debug="=full";;
  46. --warning-mode=*)
  47. warning_mode=`get_key_value "$1"`;;
  48. -c | --just-configure)
  49. just_configure=1;;
  50. -n | --just-print | --print)
  51. just_print=1;;
  52. -h | --help)
  53. usage
  54. exit 0;;
  55. *)
  56. echo "Unknown option '$1'"
  57. exit 1;;
  58. esac
  59. shift
  60. done
  61. }
  62. ########################################################################
  63. if test ! -f sql/mysqld.cc
  64. then
  65. echo "You must run this script from the MySQL top-level directory"
  66. exit 1
  67. fi
  68. prefix="/usr/local/mysql"
  69. just_print=
  70. just_configure=
  71. warning_mode=
  72. maintainer_mode=
  73. full_debug=
  74. parse_options "$@"
  75. if test -n "$MYSQL_BUILD_PREFIX"
  76. then
  77. prefix="$MYSQL_BUILD_PREFIX"
  78. fi
  79. set -e
  80. #
  81. # Check for the CPU and set up CPU specific flags. We may reset them
  82. # later.
  83. #
  84. path=`dirname $0`
  85. . "$path/check-cpu"
  86. export AM_MAKEFLAGS
  87. AM_MAKEFLAGS="-j 6"
  88. # SSL library to use.--with-ssl will select our bundled yaSSL
  89. # implementation of SSL. To use openSSl you will nee too point out
  90. # the location of openSSL headers and lbs on your system.
  91. # Ex --with-ssl=/usr
  92. SSL_LIBRARY=--with-ssl
  93. if [ "x$warning_mode" = "xpedantic" ]; then
  94. warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
  95. c_warnings="$warnings"
  96. cxx_warnings="$warnings -std=c++98"
  97. # NOTE: warning mode should not influence optimize/debug mode.
  98. # Please feel free to add a separate option if you don't feel it's an overkill.
  99. debug_extra_cflags="-O0"
  100. # Reset CPU flags (-mtune), they don't work in -pedantic mode
  101. check_cpu_cflags=""
  102. elif [ "x$warning_mode" = "xmaintainer" ]; then
  103. c_warnings="-Wall -Wextra"
  104. cxx_warnings="$c_warnings -Wno-unused-parameter"
  105. maintainer_mode="--enable-mysql-maintainer-mode"
  106. debug_extra_cflags="-g3"
  107. else
  108. # Both C and C++ warnings
  109. warnings="-Wall -Wextra -Wunused -Wwrite-strings"
  110. # For more warnings, uncomment the following line
  111. # warnings="$warnings -Wshadow"
  112. # C warnings
  113. c_warnings="$warnings"
  114. # C++ warnings
  115. cxx_warnings="$warnings -Wno-unused-parameter"
  116. # cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo"
  117. cxx_warnings="$cxx_warnings -Wnon-virtual-dtor"
  118. debug_extra_cflags="-O0 -g3 -gdwarf-2"
  119. fi
  120. # Set flags for various build configurations.
  121. # Used in -valgrind builds
  122. # Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro
  123. # LINT_INIT(), which is only useful for silencing spurious warnings
  124. # of static analysis tools. We want LINT_INIT() to be a no-op in Valgrind.
  125. valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify "
  126. valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
  127. valgrind_configs="--with-valgrind"
  128. #
  129. # Used in -debug builds
  130. debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
  131. debug_cflags="$debug_cflags -DSAFE_MUTEX"
  132. error_inject="--with-error-inject "
  133. #
  134. # Base C++ flags for all builds
  135. base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
  136. #
  137. # Flags for optimizing builds.
  138. # Be as fast as we can be without losing our ability to backtrace.
  139. fast_cflags="-O3 -fno-omit-frame-pointer"
  140. debug_configs="--with-debug"
  141. if [ -z "$full_debug" ]
  142. then
  143. debug_cflags="$debug_cflags $debug_extra_cflags"
  144. fi
  145. #
  146. # Configuration options.
  147. #
  148. base_configs="--prefix=$prefix --enable-assembler "
  149. base_configs="$base_configs --with-extra-charsets=complex "
  150. base_configs="$base_configs --enable-thread-safe-client "
  151. base_configs="$base_configs --with-big-tables $maintainer_mode"
  152. if test -d "$path/../cmd-line-utils/readline"
  153. then
  154. base_configs="$base_configs --with-readline"
  155. elif test -d "$path/../cmd-line-utils/libedit"
  156. then
  157. base_configs="$base_configs --with-libedit"
  158. fi
  159. static_link="--with-mysqld-ldflags=-all-static "
  160. static_link="$static_link --with-client-ldflags=-all-static"
  161. # we need local-infile in all binaries for rpl000001
  162. # if you need to disable local-infile in the client, write a build script
  163. # and unset local_infile_configs
  164. local_infile_configs="--enable-local-infile"
  165. max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
  166. max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb --with-embedded-server"
  167. max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server"
  168. #
  169. # CPU and platform specific compilation flags.
  170. #
  171. alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag"
  172. amd64_cflags="$check_cpu_cflags"
  173. amd64_cxxflags="" # If dropping '--with-big-tables', add here "-DBIG_TABLES"
  174. pentium_cflags="$check_cpu_cflags"
  175. pentium64_cflags="$check_cpu_cflags -m64"
  176. ppc_cflags="$check_cpu_cflags"
  177. sparc_cflags=""
  178. if gmake --version > /dev/null 2>&1
  179. then
  180. make=gmake
  181. else
  182. make=make
  183. fi
  184. if test -z "$CC" ; then
  185. CC=gcc
  186. fi
  187. if test -z "$CXX" ; then
  188. CXX=gcc
  189. fi
  190. # If ccache (a compiler cache which reduces build time)
  191. # (http://samba.org/ccache) is installed, use it.
  192. # We use 'grep' and hope 'grep' will work as expected
  193. # (returns 0 if finds lines)
  194. if test "$USING_GCOV" != "1"
  195. then
  196. # Not using gcov; Safe to use ccache
  197. CCACHE_GCOV_VERSION_ENABLED=1
  198. fi
  199. if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1"
  200. then
  201. echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
  202. echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
  203. fi
  204. # gcov
  205. # The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
  206. # code with profiling information used by gcov.
  207. # The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
  208. # The -DHAVE_gcov enables code to write out coverage info even when crashing.
  209. gcov_compile_flags="-fprofile-arcs -ftest-coverage"
  210. gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM"
  211. gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
  212. # GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
  213. # as on the compiler command line), and this requires setting LDFLAGS for BDB.
  214. gcov_link_flags="-fprofile-arcs -ftest-coverage"
  215. gcov_configs="--with-gcov"
  216. # gprof
  217. gprof_compile_flags="-O2 -pg -g"
  218. gprof_link_flags="--disable-shared $static_link"