|
|
|
|
Index: src/Makefile
|
|
|
|
|
--- src/Makefile.orig 2018-04-18 14:37:38.782186000 +0200
|
|
|
|
|
+++ src/Makefile 2018-04-18 14:40:23.340379000 +0200
|
|
|
|
|
@@ -2,32 +2,35 @@
|
|
|
|
|
# find the OS
|
|
|
|
|
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
|
|
|
|
|
|
|
|
|
-CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
|
|
|
|
|
+CC:=cc
|
|
|
|
|
export CC
|
|
|
|
|
|
|
|
|
|
# if DEBUG env var is set, we compile with "debug" cflags
|
|
|
|
|
-DEBUGFLAGS = -g -ggdb -O3
|
|
|
|
|
+DEBUGFLAGS = -O2
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
|
DEBUGFLAGS = -g -ggdb -O0
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Default CFLAGS
|
|
|
|
|
-CFLAGS += -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC \
|
|
|
|
|
- -Werror=implicit-function-declaration \
|
|
|
|
|
+CFLAGS += -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC \
|
|
|
|
|
-D_GNU_SOURCE -std=gnu99 -I"$(shell pwd)" -DREDIS_MODULE_TARGET \
|
|
|
|
|
-DREDISMODULE_EXPERIMENTAL_API
|
|
|
|
|
CFLAGS += $(DEBUGFLAGS)
|
|
|
|
|
|
|
|
|
|
LINKER=$(CC)
|
|
|
|
|
# Compile flags for non-osx / osx
|
|
|
|
|
-ifneq ($(uname_S),Darwin)
|
|
|
|
|
+ifeq ($(uname_S),Linux)
|
|
|
|
|
SHOBJ_LDFLAGS ?= -shared -Bsymbolic -Bsymbolic-functions -ldl -lpthread
|
|
|
|
|
CFLAGS += -mpopcnt
|
|
|
|
|
else
|
|
|
|
|
+ifeq ($(uname_S),FreeBSD)
|
|
|
|
|
+ SHOBJ_LDFLAGS ?= -shared -Bsymbolic -Bsymbolic-functions -pthread
|
|
|
|
|
+else
|
|
|
|
|
LINKER = $(LD)
|
|
|
|
|
CFLAGS += -mmacosx-version-min=10.6
|
|
|
|
|
SHOBJ_LDFLAGS ?= -macosx_version_min 10.6 -exported_symbol _RedisModule_OnLoad -bundle -undefined dynamic_lookup -ldl -lpthread
|
|
|
|
|
endif
|
|
|
|
|
+endif
|
|
|
|
|
export CFLAGS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Index: src/buffer.c
|
|
|
|
|
--- src/buffer.c.orig 2018-04-16 12:30:39.000000000 +0200
|
|
|
|
|
+++ src/buffer.c 2018-04-18 14:37:38.782471000 +0200
|
|
|
|
|
@@ -1,3 +1,4 @@
|
|
|
|
|
+#include <sys/types.h>
|
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "rmalloc.h"
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
Index: src/concurrent_ctx.c
|
|
|
|
|
--- src/concurrent_ctx.c.orig 2018-04-16 12:30:39.000000000 +0200
|
|
|
|
|
+++ src/concurrent_ctx.c 2018-04-18 14:37:38.782668000 +0200
|
|
|
|
|
@@ -48,7 +48,11 @@
|
|
|
|
|
/** Check the elapsed timer, and release the lock if enough time has passed */
|
|
|
|
|
int ConcurrentSearch_CheckTimer(ConcurrentSearchCtx *ctx) {
|
|
|
|
|
static struct timespec now;
|
|
|
|
|
+#ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
|
|
|
|
+#else
|
|
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
long long durationNS = (long long)1000000000 * (now.tv_sec - ctx->lastTime.tv_sec) +
|
|
|
|
|
(now.tv_nsec - ctx->lastTime.tv_nsec);
|
|
|
|
|
@@ -70,7 +74,11 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConcurrentSearchCtx_ResetClock(ConcurrentSearchCtx *ctx) {
|
|
|
|
|
+#ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &ctx->lastTime);
|
|
|
|
|
+#else
|
|
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &ctx->lastTime);
|
|
|
|
|
+#endif
|
|
|
|
|
ctx->ticker = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -153,4 +161,4 @@
|
|
|
|
|
ConcurrentSearch_CloseKeys(ctx);
|
|
|
|
|
RedisModule_ThreadSafeContextUnlock(ctx->ctx);
|
|
|
|
|
ctx->isLocked = 0;
|
|
|
|
|
-}
|
|
|
|
|
\ No newline at end of file
|
|
|
|
|
+}
|
|
|
|
|
Index: src/query.c
|
|
|
|
|
--- src/query.c.orig 2018-04-16 12:30:39.000000000 +0200
|
|
|
|
|
+++ src/query.c 2018-04-18 14:37:38.782977000 +0200
|
|
|
|
|
@@ -959,7 +959,11 @@
|
|
|
|
|
if (RSGlobalConfig.queryTimeoutMS > 0) {
|
|
|
|
|
// Check the elapsed processing time
|
|
|
|
|
static struct timespec now;
|
|
|
|
|
+#ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
|
|
|
|
+#else
|
|
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
long long durationNS = (long long)1000000000 * (now.tv_sec - q->execCtx.startTime.tv_sec) +
|
|
|
|
|
(now.tv_nsec - q->execCtx.startTime.tv_nsec);
|
|
|
|
|
@@ -1003,7 +1007,11 @@
|
|
|
|
|
.state = QueryState_OK,
|
|
|
|
|
.sctx = plan->ctx,
|
|
|
|
|
.conc = plan->conc};
|
|
|
|
|
+#ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &plan->execCtx.startTime);
|
|
|
|
|
+#else
|
|
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &plan->execCtx.startTime);
|
|
|
|
|
+#endif
|
|
|
|
|
if (plan->conc) {
|
|
|
|
|
ConcurrentSearchCtx_Init(req->sctx->redisCtx, plan->conc);
|
|
|
|
|
ConcurrentSearch_AddKey(plan->conc, plan->ctx->key, REDISMODULE_READ, plan->ctx->keyName,
|
|
|
|
|
Index: src/rmutil/sdsalloc.h
|
|
|
|
|
--- src/rmutil/sdsalloc.h.orig 2018-04-16 12:30:39.000000000 +0200
|
|
|
|
|
+++ src/rmutil/sdsalloc.h 2018-04-18 14:37:38.783152000 +0200
|
|
|
|
|
@@ -36,11 +36,7 @@
|
|
|
|
|
* the include of your alternate allocator if needed (not needed in order
|
|
|
|
|
* to use the default libc allocator). */
|
|
|
|
|
|
|
|
|
|
-#if defined(__MACH__)
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
-#else
|
|
|
|
|
-#include <malloc.h>
|
|
|
|
|
-#endif
|
|
|
|
|
//#include "zmalloc.h"
|
|
|
|
|
#define s_malloc malloc
|
|
|
|
|
#define s_realloc realloc
|