summaryrefslogtreecommitdiff
path: root/src/latency.c
diff options
context:
space:
mode:
authoryoav-steinberg <yoav@monfort.co.il>2021-08-05 08:25:58 +0300
committerGitHub <noreply@github.com>2021-08-05 08:25:58 +0300
commit5e908a290ccbe9c4a7bea9356faf3b837df62793 (patch)
treeee8c2008ef1c18653203245dd40d3befb2cd364f /src/latency.c
parent1c59567a7fe207997eef6197eefa7d508d7fbf9f (diff)
downloadredis-5e908a290ccbe9c4a7bea9356faf3b837df62793.tar.gz
dict struct memory optimizations (#9228)
Reduce dict struct memory overhead on 64bit dict size goes down from jemalloc's 96 byte bin to its 56 byte bin. summary of changes: - Remove `privdata` from callbacks and dict creation. (this affects many files, see "Interface change" below). - Meld `dictht` struct into the `dict` struct to eliminate struct padding. (this affects just dict.c and defrag.c) - Eliminate the `sizemask` field, can be calculated from size when needed. - Convert the `size` field into `size_exp` (exponent), utilizes one byte instead of 8. Interface change: pass dict pointer to dict type call back functions. This is instead of passing the removed privdata field. In the future if we'd like to have private data in the callbacks we can extract it from the dict type. We can extend dictType to include a custom dict struct allocator and use it to allocate more data at the end of the dict struct. This data can then be used to store private data later acccessed by the callbacks.
Diffstat (limited to 'src/latency.c')
-rw-r--r--src/latency.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/latency.c b/src/latency.c
index 06b94abd8..d24c7922a 100644
--- a/src/latency.c
+++ b/src/latency.c
@@ -36,8 +36,8 @@
#include "server.h"
/* Dictionary type for latency events. */
-int dictStringKeyCompare(void *privdata, const void *key1, const void *key2) {
- UNUSED(privdata);
+int dictStringKeyCompare(dict *d, const void *key1, const void *key2) {
+ UNUSED(d);
return strcmp(key1,key2) == 0;
}
@@ -45,7 +45,7 @@ uint64_t dictStringHash(const void *key) {
return dictGenHashFunction(key, strlen(key));
}
-void dictVanillaFree(void *privdata, void *val);
+void dictVanillaFree(dict *d, void *val);
dictType latencyTimeSeriesDictType = {
dictStringHash, /* hash function */
@@ -105,7 +105,7 @@ int THPGetAnonHugePagesSize(void) {
* of time series, each time series is created on demand in order to avoid
* having a fixed list to maintain. */
void latencyMonitorInit(void) {
- server.latency_events = dictCreate(&latencyTimeSeriesDictType,NULL);
+ server.latency_events = dictCreate(&latencyTimeSeriesDictType);
}
/* Add the specified sample to the specified time series "event".