diff options
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index c8f18556d50..aa4c77d0939 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -329,6 +329,9 @@ TODO list: */ #include "mariadb.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#if defined(DBUG_OFF) && defined(HAVE_MADVISE) +#include <sys/mman.h> +#endif #include "sql_priv.h" #include "sql_basic_types.h" #include "sql_cache.h" @@ -1049,7 +1052,7 @@ void query_cache_insert(void *thd_arg, const char *packet, size_t length, called for this thread. */ - if (!thd) + if (unlikely(!thd)) return; query_cache.insert(thd, &thd->query_cache_tls, @@ -2591,7 +2594,7 @@ size_t Query_cache::init_cache() { size_t mem_bin_count, num, step; size_t mem_bin_size, prev_size, inc; - size_t additional_data_size, max_mem_bin_size, approx_additional_data_size; + size_t max_mem_bin_size, approx_additional_data_size; int align; DBUG_ENTER("Query_cache::init_cache"); @@ -2656,6 +2659,13 @@ size_t Query_cache::init_cache() if (!(cache= (uchar *) my_malloc_lock(query_cache_size+additional_data_size, MYF(0)))) goto err; +#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DONTDUMP) + if (madvise(cache, query_cache_size+additional_data_size, MADV_DONTDUMP)) + { + DBUG_PRINT("warning", ("coudn't mark query cache memory as MADV_DONTDUMP: %s", + strerror(errno))); + } +#endif DBUG_PRINT("qcache", ("cache length %zu, min unit %zu, %zu bins", query_cache_size, min_allocation_unit, mem_bin_num)); @@ -2818,6 +2828,13 @@ void Query_cache::free_cache() } while (block != queries_blocks); } +#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DODUMP) + if (madvise(cache, query_cache_size+additional_data_size, MADV_DODUMP)) + { + DBUG_PRINT("warning", ("coudn't mark query cache memory as MADV_DODUMP: %s", + strerror(errno))); + } +#endif my_free(cache); make_disabled(); my_hash_free(&queries); |