From: antirez Date: Sat, 25 Jun 2011 10:29:24 +0000 (+0200) Subject: unstable merge conflicts resolved X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/994ed2bc552f4114b1f0c8dd3fd8aefaec6beeae unstable merge conflicts resolved --- 994ed2bc552f4114b1f0c8dd3fd8aefaec6beeae diff --cc Makefile index 335f8321,7ce9031c..20c4f86e --- a/Makefile +++ b/Makefile @@@ -12,7 -12,7 +12,8 @@@ clean cd src && $(MAKE) $@ cd deps/hiredis && $(MAKE) $@ cd deps/linenoise && $(MAKE) $@ + cd deps/jemalloc && $(MAKE) distclean + cd deps/lua && $(MAKE) $@ $(TARGETS): cd src && $(MAKE) $@ diff --cc redis.conf index 6999dae3,6d18e2f5..098c28da --- a/redis.conf +++ b/redis.conf @@@ -312,39 -312,6 +312,13 @@@ no-appendfsync-on-rewrite n auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb +################################ LUA SCRIPTING ############################### + +# Max execution time of a Lua script in milliseconds. +# This prevents that a programming error generating an infinite loop will block +# your server forever. Set it to 0 or a negative value for unlimited execution. +lua-time-limit 60000 + - #################################### DISK STORE ############################### - - # When disk store is active Redis works as an on-disk database, where memory - # is only used as a object cache. - # - # This mode is good for datasets that are bigger than memory, and in general - # when you want to trade speed for: - # - # - less memory used - # - immediate server restart - # - per key durability, without need for backgrond savig - # - # On the other hand, with disk store enabled MULTI/EXEC are no longer - # transactional from the point of view of the persistence on disk, that is, - # Redis transactions will still guarantee that commands are either processed - # all or nothing, but there is no guarantee that all the keys are flushed - # on disk in an atomic way. - # - # Of course with disk store enabled Redis is not as fast as it is when - # working with just the memory back end. - - diskstore-enabled no - diskstore-path redis.ds - cache-max-memory 0 - cache-flush-delay 0 - ############################### ADVANCED CONFIG ############################### # Hashes are encoded in a special way (much more memory efficient) when they diff --cc src/Makefile index e23ed038,4a6f27eb..7e4b829d --- a/src/Makefile +++ b/src/Makefile @@@ -51,7 -61,7 +61,7 @@@ QUIET_CC = @printf ' %b %b\n' $(CCCO QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR); endif - OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o dscache.o pubsub.o multi.o debug.o sort.o intset.o syncio.o diskstore.o cluster.o crc16.o endian.o scripting.o -OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endian.o ++OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endian.o scripting.o BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o @@@ -141,11 -158,12 +158,14 @@@ dependencies @cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)" @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR) @cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)" + @echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)Lua ansi$(ENDCOLOR) + @cd ../deps/lua && $(MAKE) ARCH="$(ARCH)" ansi + ../deps/jemalloc/lib/libjemalloc.a: + cd ../deps/jemalloc && ./configure $(JEMALLOC_CFLAGS) --with-jemalloc-prefix=je_ --enable-cc-silence && $(MAKE) lib/libjemalloc.a + redis-server: $(OBJ) - $(QUIET_CC)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) ../deps/lua/src/liblua.a - $(QUIET_CC)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) $(CCLINK) $(ALLOC_LINK) ++ $(QUIET_CC)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) $(CCLINK) $(ALLOC_LINK) ../deps/lua/src/liblua.a redis-benchmark: dependencies $(BENCHOBJ) @cd ../deps/hiredis && $(MAKE) static @@@ -161,13 -179,15 +181,15 @@@ redis-cli.o $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $< redis-check-dump: $(CHECKDUMPOBJ) - $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) + $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK) $(ALLOC_LINK) redis-check-aof: $(CHECKAOFOBJ) - $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) + $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK) $(ALLOC_LINK) - .c.o: + # Because the jemalloc.h header is generated as a part of the jemalloc build + # process, building it should complete before building any other object. + %.o: %.c $(ALLOC_DEP) - $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $< + $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) -I../deps/lua/src $< clean: rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov diff --cc src/redis.c index ee5e1a21,89efffba..f4e3f623 --- a/src/redis.c +++ b/src/redis.c @@@ -886,10 -833,8 +837,9 @@@ void initServerConfig() server.zset_max_ziplist_entries = REDIS_ZSET_MAX_ZIPLIST_ENTRIES; server.zset_max_ziplist_value = REDIS_ZSET_MAX_ZIPLIST_VALUE; server.shutdown_asap = 0; - server.cache_flush_delay = 0; server.cluster_enabled = 0; server.cluster.configfile = zstrdup("nodes.conf"); + server.lua_time_limit = REDIS_LUA_TIME_LIMIT; updateLRUClock(); resetServerSaveParams(); @@@ -1014,9 -951,7 +956,8 @@@ void initServer() } } - if (server.ds_enabled) dsInit(); if (server.cluster_enabled) clusterInit(); + scriptingInit(); srand(time(NULL)^getpid()); } @@@ -1362,9 -1292,8 +1299,9 @@@ sds genRedisInfoString(char *section) zmalloc_get_rss(), server.stat_peak_memory, peak_hmem, + ((long long)lua_gc(server.lua,LUA_GCCOUNT,0))*1024LL, zmalloc_get_fragmentation_ratio(), - REDIS_MALLOC + ZMALLOC_LIB ); } diff --cc src/redis.h index fec7355b,a5cd15ed..9775e298 --- a/src/redis.h +++ b/src/redis.h @@@ -224,15 -208,6 +210,9 @@@ #define REDIS_MAXMEMORY_ALLKEYS_RANDOM 4 #define REDIS_MAXMEMORY_NO_EVICTION 5 - /* Diskstore background saving thread states */ - #define REDIS_BGSAVE_THREAD_UNACTIVE 0 - #define REDIS_BGSAVE_THREAD_ACTIVE 1 - #define REDIS_BGSAVE_THREAD_DONE_OK 2 - #define REDIS_BGSAVE_THREAD_DONE_ERR 3 - +/* Scripting */ +#define REDIS_LUA_TIME_LIMIT 60000 /* milliseconds */ + /* We can print the stacktrace, so our assert is defined this way: */ #define redisAssert(_e) ((_e)?(void)0 : (_redisAssert(#_e,__FILE__,__LINE__),_exit(1))) #define redisPanic(_e) _redisPanic(#_e,__FILE__,__LINE__),_exit(1)