summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2018-06-19 16:59:45 +0300
committerOran Agra <oran@redislabs.com>2018-06-19 18:18:23 +0300
commit482785ac62aab0bcaf53eb7eb6f7e005629ff0fa (patch)
tree6b95589dc3967b27e43585ae4599cab55e8631d5
parent44571088d8407749ca1c49cde09089664e7928ff (diff)
downloadredis-482785ac62aab0bcaf53eb7eb6f7e005629ff0fa.tar.gz
add malloc_usable_size for libc malloc
this reduces the extra 8 bytes we save before each pointer. but more importantly maybe, it makes the valgrind runs to be more similiar to our normal runs. note: the change in malloc_stats struct in server.h is to eliminate an name conflict. structs that are not typedefed are resolved from a separate name space.
-rw-r--r--src/server.h6
-rw-r--r--src/zmalloc.h5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/server.h b/src/server.h
index e3bba8ace..f7aff36b1 100644
--- a/src/server.h
+++ b/src/server.h
@@ -882,13 +882,13 @@ typedef struct rdbSaveInfo {
#define RDB_SAVE_INFO_INIT {-1,0,"000000000000000000000000000000",-1}
-typedef struct malloc_stats {
+struct malloc_stats {
size_t zmalloc_used;
size_t process_rss;
size_t allocator_allocated;
size_t allocator_active;
size_t allocator_resident;
-} malloc_stats;
+};
/*-----------------------------------------------------------------------------
* Global server state
@@ -995,7 +995,7 @@ struct redisServer {
long long slowlog_entry_id; /* SLOWLOG current entry ID */
long long slowlog_log_slower_than; /* SLOWLOG time limit (to get logged) */
unsigned long slowlog_max_len; /* SLOWLOG max number of items logged */
- malloc_stats cron_malloc_stats; /* sampled in serverCron(). */
+ struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */
long long stat_net_input_bytes; /* Bytes read from network. */
long long stat_net_output_bytes; /* Bytes written to network. */
size_t stat_rdb_cow_bytes; /* Copy on write bytes during RDB saving. */
diff --git a/src/zmalloc.h b/src/zmalloc.h
index 3c926bcbe..49b33b883 100644
--- a/src/zmalloc.h
+++ b/src/zmalloc.h
@@ -63,6 +63,11 @@
#ifndef ZMALLOC_LIB
#define ZMALLOC_LIB "libc"
+#ifdef __GLIBC__
+#include <malloc.h>
+#define HAVE_MALLOC_SIZE 1
+#define zmalloc_size(p) malloc_usable_size(p)
+#endif
#endif
/* We can enable the Redis defrag capabilities only if we are using Jemalloc