summaryrefslogtreecommitdiff
path: root/src/redisassert.h
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2020-09-08 15:51:20 +0300
committerOran Agra <oran@redislabs.com>2020-12-06 14:54:34 +0200
commite288430c05359706bcb0f78730af2997ab0db07f (patch)
treef164e852d7661ddfa50b0ff660a08d44cd4ef4f4 /src/redisassert.h
parent7ca00d694d44be13a3ff9ff1c96b49222ac9463b (diff)
downloadredis-e288430c05359706bcb0f78730af2997ab0db07f.tar.gz
Sanitize dump payload: performance optimizations and tuning
First, if the ziplist header is surely inside the ziplist, do fast path decoding rather than the careful one. In that case, streamline the encoding if-else chain to be executed only once, and the encoding validity tested at the end. encourage inlining likely / unlikely hints for speculative execution Assertion used _exit(1) to tell the compiler that the code after them is not reachable and get rid of warnings. But in some cases assertions are placed inside tight loops, and any piece of code in them can slow down execution (code cache and other reasons), instead using either abort() or better yet, unreachable builtin.
Diffstat (limited to 'src/redisassert.h')
-rw-r--r--src/redisassert.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/redisassert.h b/src/redisassert.h
index 61ab35a14..dd7920554 100644
--- a/src/redisassert.h
+++ b/src/redisassert.h
@@ -38,10 +38,10 @@
#ifndef __REDIS_ASSERT_H__
#define __REDIS_ASSERT_H__
-#include <unistd.h> /* for _exit() */
+#include "config.h"
-#define assert(_e) ((_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),_exit(1)))
-#define panic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),_exit(1)
+#define assert(_e) (likely((_e))?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),redis_unreachable()))
+#define panic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),redis_unreachable()
void _serverAssert(char *estr, char *file, int line);
void _serverPanic(const char *file, int line, const char *msg, ...);