From 6410b4f19a0025a1ba16685c3a26b34a1ae03c3f Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 30 Jan 2018 13:27:41 +0200 Subject: [PATCH] MXS-1633 Turn off collecting of sqlite3 memstats According to customer reports collecting the statistics has a significant impact on the performance. As we don't need that information we can just as well turn off that. Further, since maxscale-common now links to the sqlite3-library, no module needs to do that explicitly. --- server/core/CMakeLists.txt | 1 + server/core/gateway.cc | 39 +++++++++++++++++++ .../authenticator/MySQLAuth/CMakeLists.txt | 2 +- .../modules/routing/avrorouter/CMakeLists.txt | 2 +- .../routing/binlogrouter/CMakeLists.txt | 4 +- .../routing/binlogrouter/test/CMakeLists.txt | 2 +- 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index a76c021dc..a6c6e979d 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -73,6 +73,7 @@ target_link_libraries(maxscale-common z rt m + sqlite3 stdc++ gnutls gcrypt diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 1d900d42f..d2caf5695 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -189,6 +190,7 @@ static void disable_module_unloading(const char* arg); static void enable_module_unloading(const char* arg); static void redirect_output_to_file(const char* arg); static bool user_is_acceptable(const char* specified_user); +static bool init_sqlite3(); struct DEBUG_ARGUMENT { @@ -1957,6 +1959,13 @@ int main(int argc, char **argv) } } + if (!init_sqlite3()) + { + MXS_ERROR("Could not initialize sqlite3, exiting."); + rc = MAXSCALE_INTERNALERROR; + goto return_main; + } + MXS_NOTICE("MariaDB MaxScale %s started", MAXSCALE_VERSION); MXS_NOTICE("MaxScale is running in process %i", getpid()); @@ -3304,3 +3313,33 @@ static bool user_is_acceptable(const char* specified_user) return acceptable; } + +static bool init_sqlite3() +{ + bool rv = true; + + // Collecting the memstatus introduces locking that, according to customer reports, + // has a significant impact on the performance. + if (sqlite3_config(SQLITE_CONFIG_MEMSTATUS, (int)0) == SQLITE_OK) // 0 turns off. + { + MXS_NOTICE("The collection of SQLite memory allocation statistics turned off."); + } + else + { + MXS_WARNING("Could not turn off the collection of SQLite memory allocation statistics."); + // Non-fatal, we simply will take a small performance hit. + } + + if (sqlite3_config(SQLITE_CONFIG_MULTITHREAD) == SQLITE_OK) + { + MXS_NOTICE("Threading mode of SQLite set to Multi-thread."); + } + else + { + MXS_ERROR("Could not set the threading mode of SQLite to Multi-thread. " + "MaxScale will terminate."); + rv = false; + } + + return rv; +} diff --git a/server/modules/authenticator/MySQLAuth/CMakeLists.txt b/server/modules/authenticator/MySQLAuth/CMakeLists.txt index a4aa424f1..d6ac92947 100644 --- a/server/modules/authenticator/MySQLAuth/CMakeLists.txt +++ b/server/modules/authenticator/MySQLAuth/CMakeLists.txt @@ -2,7 +2,7 @@ if(SQLITE_VERSION VERSION_LESS 3.3) message(FATAL_ERROR "SQLite version 3.3 or higher is required") else() add_library(mysqlauth SHARED mysql_auth.c dbusers.c) - target_link_libraries(mysqlauth maxscale-common mysqlcommon sqlite3) + target_link_libraries(mysqlauth maxscale-common mysqlcommon) set_target_properties(mysqlauth PROPERTIES VERSION "1.0.0") install_module(mysqlauth core) endif() diff --git a/server/modules/routing/avrorouter/CMakeLists.txt b/server/modules/routing/avrorouter/CMakeLists.txt index d852862bb..c9be3ddfd 100644 --- a/server/modules/routing/avrorouter/CMakeLists.txt +++ b/server/modules/routing/avrorouter/CMakeLists.txt @@ -4,7 +4,7 @@ if(AVRO_FOUND AND JANSSON_FOUND) add_library(avrorouter SHARED avro.c ../binlogrouter/binlog_common.c avro_client.c avro_schema.c avro_rbr.c avro_file.c avro_index.c) set_target_properties(avrorouter PROPERTIES VERSION "1.0.0") set_target_properties(avrorouter PROPERTIES LINK_FLAGS -Wl,-z,defs) - target_link_libraries(avrorouter maxscale-common ${JANSSON_LIBRARIES} ${AVRO_LIBRARIES} maxavro sqlite3 lzma) + target_link_libraries(avrorouter maxscale-common ${JANSSON_LIBRARIES} ${AVRO_LIBRARIES} maxavro lzma) install_module(avrorouter core) else() message(STATUS "No Avro C or Jansson libraries found, not building avrorouter.") diff --git a/server/modules/routing/binlogrouter/CMakeLists.txt b/server/modules/routing/binlogrouter/CMakeLists.txt index d28ebae1a..a847e9792 100644 --- a/server/modules/routing/binlogrouter/CMakeLists.txt +++ b/server/modules/routing/binlogrouter/CMakeLists.txt @@ -1,11 +1,11 @@ add_library(binlogrouter SHARED blr.c blr_master.c blr_cache.c blr_slave.c blr_file.c) set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "2.0.0") set_target_properties(binlogrouter PROPERTIES LINK_FLAGS -Wl,-z,defs) -target_link_libraries(binlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid sqlite3) +target_link_libraries(binlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid) install_module(binlogrouter core) add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master.c blr_slave.c blr.c) -target_link_libraries(maxbinlogcheck maxscale-common ${PCRE_LINK_FLAGS} uuid sqlite3) +target_link_libraries(maxbinlogcheck maxscale-common ${PCRE_LINK_FLAGS} uuid) install_executable(maxbinlogcheck core) diff --git a/server/modules/routing/binlogrouter/test/CMakeLists.txt b/server/modules/routing/binlogrouter/test/CMakeLists.txt index e93f9306a..d600418eb 100644 --- a/server/modules/routing/binlogrouter/test/CMakeLists.txt +++ b/server/modules/routing/binlogrouter/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(BUILD_TESTS) add_executable(testbinlogrouter testbinlog.c ../blr.c ../blr_slave.c ../blr_master.c ../blr_file.c ../blr_cache.c) - target_link_libraries(testbinlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid sqlite3) + target_link_libraries(testbinlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid) add_test(NAME TestBinlogRouter COMMAND ./testbinlogrouter WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif()