2011-11-15 15:40:49 -05:00
|
|
|
# Redis dependency Makefile
|
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
2011-11-15 15:40:49 -05:00
|
|
|
|
2021-11-28 04:33:09 -05:00
|
|
|
LUA_DEBUG?=no
|
|
|
|
|
2011-11-15 15:40:49 -05: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-24 22:25:03 -04: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 15:40:49 -05:00
|
|
|
endif
|
|
|
|
|
2012-03-24 22:25:03 -04: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 15:40:49 -05: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 14:21:29 -04: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 05:17:41 -04:00
|
|
|
-(cd fpconv && $(MAKE) clean) > /dev/null || true
|
2012-03-24 22:25:03 -04: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 03:53:56 -04:00
|
|
|
ifneq (,$(filter $(BUILD_TLS),yes module))
|
2019-09-12 03:56:54 -04:00
|
|
|
HIREDIS_MAKE_FLAGS = USE_SSL=1
|
|
|
|
endif
|
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
hiredis: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
2019-09-12 03:56:54 -04:00
|
|
|
cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
|
2012-03-24 22:25:03 -04:00
|
|
|
|
|
|
|
.PHONY: hiredis
|
|
|
|
|
|
|
|
linenoise: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
|
|
cd linenoise && $(MAKE)
|
|
|
|
|
|
|
|
.PHONY: linenoise
|
|
|
|
|
2020-08-25 14:21:29 -04: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 05:17:41 -04:00
|
|
|
fpconv: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
|
|
cd fpconv && $(MAKE)
|
|
|
|
|
|
|
|
.PHONY: fpconv
|
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
ifeq ($(uname_S),SunOS)
|
2013-03-16 03:35:20 -04:00
|
|
|
# Make isinf() available
|
|
|
|
LUA_CFLAGS= -D__C99FEATURES__=1
|
2012-03-24 22:25:03 -04:00
|
|
|
endif
|
|
|
|
|
2021-11-28 04:33:09 -05:00
|
|
|
LUA_CFLAGS+= -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP $(CFLAGS)
|
2012-03-24 22:25:03 -04:00
|
|
|
LUA_LDFLAGS+= $(LDFLAGS)
|
2021-11-28 04:33:09 -05:00
|
|
|
ifeq ($(LUA_DEBUG),yes)
|
|
|
|
LUA_CFLAGS+= -O0 -g -DLUA_USE_APICHECK
|
|
|
|
else
|
|
|
|
LUA_CFLAGS+= -O2
|
|
|
|
endif
|
2013-03-11 21:04:40 -04: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 10:10:54 -04:00
|
|
|
ARFLAGS=rc
|
2011-11-15 15:40:49 -05:00
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
lua: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
2013-03-11 21:04:40 -04:00
|
|
|
cd lua/src && $(MAKE) all CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(LUA_LDFLAGS)" AR="$(AR) $(ARFLAGS)"
|
2011-11-15 15:40:49 -05:00
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
.PHONY: lua
|
2011-11-15 15:40:49 -05:00
|
|
|
|
2023-02-02 09:58:16 -05:00
|
|
|
JEMALLOC_CFLAGS=$(CFLAGS)
|
|
|
|
JEMALLOC_LDFLAGS=$(LDFLAGS)
|
2011-11-15 15:40:49 -05:00
|
|
|
|
2021-10-24 03:15:32 -04:00
|
|
|
ifneq ($(DEB_HOST_GNU_TYPE),)
|
|
|
|
JEMALLOC_CONFIGURE_OPTS += --host=$(DEB_HOST_GNU_TYPE)
|
|
|
|
endif
|
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
jemalloc: .make-prerequisites
|
|
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
2023-02-02 09:58:16 -05:00
|
|
|
cd jemalloc && ./configure --disable-cxx --with-version=5.2.1-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" $(JEMALLOC_CONFIGURE_OPTS)
|
|
|
|
cd jemalloc && $(MAKE) lib/libjemalloc.a
|
2011-11-15 15:40:49 -05:00
|
|
|
|
2012-03-24 22:25:03 -04:00
|
|
|
.PHONY: jemalloc
|