2024-04-09 08:24:03 +00:00
|
|
|
# Dependency Makefile
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2021-11-28 09:33:09 +00:00
|
|
|
LUA_DEBUG?=no
|
2023-07-10 07:26:09 +00:00
|
|
|
LUA_COVERAGE?=no
|
2021-11-28 09:33:09 +00:00
|
|
|
|
2011-11-15 20:40:49 +00:00
|
|
|
CCCOLOR="\033[34m"
|
|
|
|
LINKCOLOR="\033[34;1m"
|
|
|
|
SRCCOLOR="\033[33m"
|
|
|
|
BINCOLOR="\033[37;1m"
|
|
|
|
MAKECOLOR="\033[32;1m"
|
|
|
|
ENDCOLOR="\033[0m"
|
|
|
|
|
|
|
|
default:
|
|
|
|
@echo "Explicit target required"
|
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
.PHONY: default
|
|
|
|
|
|
|
|
# Prerequisites target
|
|
|
|
.make-prerequisites:
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
# Clean everything when CFLAGS is different
|
|
|
|
ifneq ($(shell sh -c '[ -f .make-cflags ] && cat .make-cflags || echo none'), $(CFLAGS))
|
|
|
|
.make-cflags: distclean
|
|
|
|
-(echo "$(CFLAGS)" > .make-cflags)
|
|
|
|
.make-prerequisites: .make-cflags
|
2011-11-15 20:40:49 +00:00
|
|
|
endif
|
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
# Clean everything when LDFLAGS is different
|
|
|
|
ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'), $(LDFLAGS))
|
|
|
|
.make-ldflags: distclean
|
|
|
|
-(echo "$(LDFLAGS)" > .make-ldflags)
|
|
|
|
.make-prerequisites: .make-ldflags
|
|
|
|
endif
|
2011-11-15 20:40:49 +00:00
|
|
|
|
|
|
|
distclean:
|
|
|
|
-(cd hiredis && $(MAKE) clean) > /dev/null || true
|
|
|
|
-(cd linenoise && $(MAKE) clean) > /dev/null || true
|
|
|
|
-(cd lua && $(MAKE) clean) > /dev/null || true
|
|
|
|
-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
|
2020-08-25 18:21:29 +00:00
|
|
|
-(cd hdr_histogram && $(MAKE) clean) > /dev/null || true
|
optimizing d2string() and addReplyDouble() with grisu2: double to string conversion based on Florian Loitsch's Grisu-algorithm (#10587)
All commands / use cases that heavily rely on double to a string representation conversion,
(e.g. meaning take a double-precision floating-point number like 1.5 and return a string like "1.5" ),
could benefit from a performance boost by swapping snprintf(buf,len,"%.17g",value) by the
equivalent [fpconv_dtoa](https://github.com/night-shift/fpconv) or any other algorithm that ensures
100% coverage of conversion.
This is a well-studied topic and Projects like MongoDB. RedPanda, PyTorch leverage libraries
( fmtlib ) that use the optimized double to string conversion underneath.
The positive impact can be substantial. This PR uses the grisu2 approach ( grisu explained on
https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf section 5 ).
test suite changes:
Despite being compatible, in some cases it produces a different result from printf, and some tests
had to be adjusted.
one case is that `%.17g` (which means %e or %f which ever is shorter), chose to use `5000000000`
instead of 5e+9, which sounds like a bug?
In other cases, we changed TCL to compare numbers instead of strings to ignore minor rounding
issues (`expr 0.8 == 0.79999999999999999`)
2022-10-15 09:17:41 +00:00
|
|
|
-(cd fpconv && $(MAKE) clean) > /dev/null || true
|
2012-03-25 02:25:03 +00:00
|
|
|
-(rm -f .make-*)
|
|
|
|
|
|
|
|
.PHONY: distclean
|
|
|
|
|
Build TLS as a loadable module
* Support BUILD_TLS=module to be loaded as a module via config file or
command line. e.g. redis-server --loadmodule redis-tls.so
* Updates to redismodule.h to allow it to be used side by side with
server.h by defining REDISMODULE_CORE_MODULE
* Changes to server.h, redismodule.h and module.c to avoid repeated
type declarations (gcc 4.8 doesn't like these)
* Add a mechanism for non-ABI neutral modules (ones who include
server.h) to refuse loading if they detect not being built together with
redis (release.c)
* Fix wrong signature of RedisModuleDefragFunc, this could break
compilation of a module, but not the ABI
* Move initialization of listeners in server.c to be after loading
the modules
* Config TLS after initialization of listeners
* Init cluster after initialization of listeners
* Add TLS module to CI
* Fix a test suite race conditions:
Now that the listeners are initialized later, it's not sufficient to
wait for the PID message in the log, we need to wait for the "Server
Initialized" message.
* Fix issues with moduleconfigs test as a result from start_server
waiting for "Server Initialized"
* Fix issues with modules/infra test as a result of an additional module
present
Notes about Sentinel:
Sentinel can't really rely on the tls module, since it uses hiredis to
initiate connections and depends on OpenSSL (won't be able to use any
other connection modules for that), so it was decided that when TLS is
built as a module, sentinel does not support TLS at all.
This means that it keeps using redis_tls_ctx and redis_tls_client_ctx directly.
Example code of config in redis-tls.so(may be use in the future):
RedisModuleString *tls_cfg = NULL;
void tlsInfo(RedisModuleInfoCtx *ctx, int for_crash_report) {
UNUSED(for_crash_report);
RedisModule_InfoAddSection(ctx, "");
RedisModule_InfoAddFieldLongLong(ctx, "var", 42);
}
int tlsCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
{
if (argc != 2) return RedisModule_WrongArity(ctx);
return RedisModule_ReplyWithString(ctx, argv[1]);
}
RedisModuleString *getStringConfigCommand(const char *name, void *privdata) {
REDISMODULE_NOT_USED(name);
REDISMODULE_NOT_USED(privdata);
return tls_cfg;
}
int setStringConfigCommand(const char *name, RedisModuleString *new, void *privdata, RedisModuleString **err) {
REDISMODULE_NOT_USED(name);
REDISMODULE_NOT_USED(err);
REDISMODULE_NOT_USED(privdata);
if (tls_cfg) RedisModule_FreeString(NULL, tls_cfg);
RedisModule_RetainString(NULL, new);
tls_cfg = new;
return REDISMODULE_OK;
}
int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc)
{
....
if (RedisModule_CreateCommand(ctx,"tls",tlsCommand,"",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
if (RedisModule_RegisterStringConfig(ctx, "cfg", "", REDISMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL) == REDISMODULE_ERR)
return REDISMODULE_ERR;
if (RedisModule_LoadConfigs(ctx) == REDISMODULE_ERR) {
if (tls_cfg) {
RedisModule_FreeString(ctx, tls_cfg);
tls_cfg = NULL;
}
return REDISMODULE_ERR;
}
...
}
Co-authored-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-08-22 07:53:56 +00:00
|
|
|
ifneq (,$(filter $(BUILD_TLS),yes module))
|
2019-09-12 07:56:54 +00:00
|
|
|
HIREDIS_MAKE_FLAGS = USE_SSL=1
|
|
|
|
endif
|
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
hiredis: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
2019-09-12 07:56:54 +00:00
|
|
|
cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
|
2012-03-25 02:25:03 +00:00
|
|
|
|
|
|
|
.PHONY: hiredis
|
|
|
|
|
|
|
|
linenoise: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
|
|
cd linenoise && $(MAKE)
|
|
|
|
|
|
|
|
.PHONY: linenoise
|
|
|
|
|
2020-08-25 18:21:29 +00:00
|
|
|
hdr_histogram: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
|
|
cd hdr_histogram && $(MAKE)
|
|
|
|
|
|
|
|
.PHONY: hdr_histogram
|
|
|
|
|
optimizing d2string() and addReplyDouble() with grisu2: double to string conversion based on Florian Loitsch's Grisu-algorithm (#10587)
All commands / use cases that heavily rely on double to a string representation conversion,
(e.g. meaning take a double-precision floating-point number like 1.5 and return a string like "1.5" ),
could benefit from a performance boost by swapping snprintf(buf,len,"%.17g",value) by the
equivalent [fpconv_dtoa](https://github.com/night-shift/fpconv) or any other algorithm that ensures
100% coverage of conversion.
This is a well-studied topic and Projects like MongoDB. RedPanda, PyTorch leverage libraries
( fmtlib ) that use the optimized double to string conversion underneath.
The positive impact can be substantial. This PR uses the grisu2 approach ( grisu explained on
https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf section 5 ).
test suite changes:
Despite being compatible, in some cases it produces a different result from printf, and some tests
had to be adjusted.
one case is that `%.17g` (which means %e or %f which ever is shorter), chose to use `5000000000`
instead of 5e+9, which sounds like a bug?
In other cases, we changed TCL to compare numbers instead of strings to ignore minor rounding
issues (`expr 0.8 == 0.79999999999999999`)
2022-10-15 09:17:41 +00:00
|
|
|
fpconv: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
|
|
cd fpconv && $(MAKE)
|
|
|
|
|
|
|
|
.PHONY: fpconv
|
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
ifeq ($(uname_S),SunOS)
|
2013-03-16 07:35:20 +00:00
|
|
|
# Make isinf() available
|
|
|
|
LUA_CFLAGS= -D__C99FEATURES__=1
|
2012-03-25 02:25:03 +00:00
|
|
|
endif
|
|
|
|
|
2024-06-26 16:47:59 +00:00
|
|
|
LUA_CFLAGS+= -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DLUA_USE_MKSTEMP $(CFLAGS)
|
2012-03-25 02:25:03 +00:00
|
|
|
LUA_LDFLAGS+= $(LDFLAGS)
|
2021-11-28 09:33:09 +00:00
|
|
|
ifeq ($(LUA_DEBUG),yes)
|
|
|
|
LUA_CFLAGS+= -O0 -g -DLUA_USE_APICHECK
|
|
|
|
else
|
|
|
|
LUA_CFLAGS+= -O2
|
|
|
|
endif
|
2023-07-10 07:26:09 +00:00
|
|
|
ifeq ($(LUA_COVERAGE),yes)
|
|
|
|
LUA_CFLAGS += -fprofile-arcs -ftest-coverage
|
|
|
|
LUA_LDFLAGS += -fprofile-arcs -ftest-coverage
|
|
|
|
endif
|
|
|
|
|
2013-03-12 01:04:40 +00:00
|
|
|
# lua's Makefile defines AR="ar rcu", which is unusual, and makes it more
|
|
|
|
# challenging to cross-compile lua (and redis). These defines make it easier
|
|
|
|
# to fit redis into cross-compilation environments, which typically set AR.
|
|
|
|
AR=ar
|
2020-09-29 14:10:54 +00:00
|
|
|
ARFLAGS=rc
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
lua: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
2013-03-12 01:04:40 +00:00
|
|
|
cd lua/src && $(MAKE) all CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(LUA_LDFLAGS)" AR="$(AR) $(ARFLAGS)"
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
.PHONY: lua
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2023-02-02 14:58:16 +00:00
|
|
|
JEMALLOC_CFLAGS=$(CFLAGS)
|
|
|
|
JEMALLOC_LDFLAGS=$(LDFLAGS)
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2021-10-24 07:15:32 +00:00
|
|
|
ifneq ($(DEB_HOST_GNU_TYPE),)
|
|
|
|
JEMALLOC_CONFIGURE_OPTS += --host=$(DEB_HOST_GNU_TYPE)
|
|
|
|
endif
|
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
jemalloc: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
Set Jemalloc --disable-cache-oblivious to reduce memory overhead (#12315)
Apparently for large size classes Jemalloc allocate some extra
memory (can be up to 25% overhead for allocations of 16kb).
see https://github.com/jemalloc/jemalloc/issues/1098#issuecomment-1589870476
p.s. from Redis's perspective that looks like external fragmentation,
(i.e. allocated bytes will be low, and active pages bytes will be large)
which can cause active-defrag to eat CPU cycles in vain.
Some details about this mechanism we disable:
---------------------------------------------------------------
Disabling this mechanism only affects large allocations (above 16kb)
Not only that it isn't expected to cause any performance regressions,
it's actually recommended, unless you have a specific workload pattern
and hardware that benefit from this feature -- by default it's enabled and
adds address randomization to all large buffers, by over allocating 1 page
per large size class, and offsetting into that page to make the starting
address of the user buffer randomized. Workloads such as scientific
computation often handle multiple big matrixes at the same time, and the
randomization makes sure that the cacheline level accesses don't suffer
bad conflicts (when they all start from page-aligned addresses).
However the downsize is also quite noticeable, like you observed that extra
page per large size can cause memory overhead, plus the extra TLB entry.
The other factor is, hardware in the last few years started doing the
randomization at the hardware level, i.e. the address to cacheline mapping isn't
a direct mapping anymore. So there's debate to disable the randomization by default,
but we are still hesitant because when it matters, it could matter a lot, and having
it enabled by default limits that worst case behavior, even though it means the
majority of workloads suffers a regression.
So in short, it's safe and offers better performance in most cases.
2023-06-18 07:30:23 +00:00
|
|
|
cd jemalloc && ./configure --disable-cxx --with-version=5.3.0-0-g0 --with-lg-quantum=3 --disable-cache-oblivious --with-jemalloc-prefix=je_ CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" $(JEMALLOC_CONFIGURE_OPTS)
|
2023-02-02 14:58:16 +00:00
|
|
|
cd jemalloc && $(MAKE) lib/libjemalloc.a
|
2011-11-15 20:40:49 +00:00
|
|
|
|
2012-03-25 02:25:03 +00:00
|
|
|
.PHONY: jemalloc
|