mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
29380ff77d
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`)
113 lines
3.2 KiB
Makefile
113 lines
3.2 KiB
Makefile
# Redis dependency Makefile
|
|
|
|
uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
|
|
|
LUA_DEBUG?=no
|
|
|
|
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"
|
|
|
|
.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
|
|
endif
|
|
|
|
# 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
|
|
|
|
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
|
|
-(cd hdr_histogram && $(MAKE) clean) > /dev/null || true
|
|
-(cd fpconv && $(MAKE) clean) > /dev/null || true
|
|
-(rm -f .make-*)
|
|
|
|
.PHONY: distclean
|
|
|
|
ifneq (,$(filter $(BUILD_TLS),yes module))
|
|
HIREDIS_MAKE_FLAGS = USE_SSL=1
|
|
endif
|
|
|
|
hiredis: .make-prerequisites
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
|
|
|
|
.PHONY: hiredis
|
|
|
|
linenoise: .make-prerequisites
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
cd linenoise && $(MAKE)
|
|
|
|
.PHONY: linenoise
|
|
|
|
hdr_histogram: .make-prerequisites
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
cd hdr_histogram && $(MAKE)
|
|
|
|
.PHONY: hdr_histogram
|
|
|
|
fpconv: .make-prerequisites
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
cd fpconv && $(MAKE)
|
|
|
|
.PHONY: fpconv
|
|
|
|
ifeq ($(uname_S),SunOS)
|
|
# Make isinf() available
|
|
LUA_CFLAGS= -D__C99FEATURES__=1
|
|
endif
|
|
|
|
LUA_CFLAGS+= -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP $(CFLAGS)
|
|
LUA_LDFLAGS+= $(LDFLAGS)
|
|
ifeq ($(LUA_DEBUG),yes)
|
|
LUA_CFLAGS+= -O0 -g -DLUA_USE_APICHECK
|
|
else
|
|
LUA_CFLAGS+= -O2
|
|
endif
|
|
# 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
|
|
ARFLAGS=rc
|
|
|
|
lua: .make-prerequisites
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
cd lua/src && $(MAKE) all CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(LUA_LDFLAGS)" AR="$(AR) $(ARFLAGS)"
|
|
|
|
.PHONY: lua
|
|
|
|
JEMALLOC_CFLAGS= -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops $(CFLAGS)
|
|
JEMALLOC_LDFLAGS= $(LDFLAGS)
|
|
|
|
ifneq ($(DEB_HOST_GNU_TYPE),)
|
|
JEMALLOC_CONFIGURE_OPTS += --host=$(DEB_HOST_GNU_TYPE)
|
|
endif
|
|
|
|
jemalloc: .make-prerequisites
|
|
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
|
cd jemalloc && ./configure --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) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a
|
|
|
|
.PHONY: jemalloc
|