Skip to content

Commit

Permalink
1. Refactor lmdb's engine impl, it's much faster&stable now.
Browse files Browse the repository at this point in the history
2. A potential crash fix in buffer.cpp
3. Upgrade lmdb to 0.9.11, rocksdb to 3.1, jemalloc to 3.6.0, snappy to 1.1.2
  • Loading branch information
yinqiwen committed May 29, 2014
1 parent be71ed7 commit 13921f0
Show file tree
Hide file tree
Showing 22 changed files with 667 additions and 495 deletions.
19 changes: 18 additions & 1 deletion ardb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ leveldb.batch_commit_watermark 1024
# This can be one of snappy/none
leveldb.compression snappy

#lmdb's options
lmdb.database_max_size 10G
lmdb.readahead no
lmdb.batch_commit_watermark 1024

#rocksdb's options, similar to leveldb's options
rocksdb.block_cache_size 512m
rocksdb.block_size 0
rocksdb.write_buffer_size 128m
rocksdb.block_restart_interval 0
rocksdb.max_open_files 1024
rocksdb.bloom_bits 10
rocksdb.batch_commit_watermark 1024
# Specify the rocksdb compression
# This can be one of snappy/none
rocksdb.compression snappy


# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
Expand Down Expand Up @@ -83,7 +100,7 @@ tcp-keepalive 0
# info
# debug
# trace
loglevel debug
loglevel info

# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output. Note that if you use standard
Expand Down
Binary file added deps/LMDB_0.9.11.tar.gz
Binary file not shown.
Binary file removed deps/LMDB_0_9_6.gz
Binary file not shown.
Binary file removed deps/jemalloc-3.5.0.tar.bz2
Binary file not shown.
Binary file added deps/jemalloc-3.6.0.tar.bz2
Binary file not shown.
Binary file removed deps/rocksdb-2.7.fb.tar.gz
Binary file not shown.
Binary file added deps/rocksdb-rocksdb-3.1.tar.gz
Binary file not shown.
Binary file removed deps/snappy-1.1.1.tar.gz
Binary file not shown.
Binary file added deps/snappy-1.1.2.tar.gz
Binary file not shown.
34 changes: 6 additions & 28 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@
CXX=g++
CC=gcc

ARDB_VERSION=0.7.1
ARDB_VERSION=0.7.2

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')

LIB_PATH=$(PWD)/../deps

LMDB_PATH=${LIB_PATH}/mdb-mdb/libraries/liblmdb
LMDB_FILE=${LIB_PATH}/LMDB_0_9_6.gz
LMDB_FILE=${LIB_PATH}/LMDB_0.9.11.tar.gz
LMDB_LIBA=${LMDB_PATH}/liblmdb.a

JEMALLOC_VER=jemalloc-3.5.0
JEMALLOC_VER=jemalloc-3.6.0
JEMALLOC_PATH=${LIB_PATH}/${JEMALLOC_VER}
JEMALLOC_FILE=${JEMALLOC_PATH}.tar.bz2
JEMALLOC_LIBA=${JEMALLOC_PATH}/lib/libjemalloc.a

SNAPPY_VER=snappy-1.1.1
SNAPPY_VER=snappy-1.1.2
SNAPPY_PATH=${LIB_PATH}/${SNAPPY_VER}
SNAPPY_FILE=${SNAPPY_PATH}.tar.gz
SNAPPY_LIBA=${SNAPPY_PATH}/.libs/libsnappy.a
Expand All @@ -59,7 +59,7 @@ LEVELDB_PATH=${LIB_PATH}/${LEVELDB_VER}
LEVELDB_FILE=${LEVELDB_PATH}.tar.gz
LEVELDB_LIBA=${LEVELDB_PATH}/libleveldb.a

ROCKSDB_VER=rocksdb-2.7.fb
ROCKSDB_VER=rocksdb-rocksdb-3.1
ROCKSDB_PATH=${LIB_PATH}/${ROCKSDB_VER}
ROCKSDB_FILE=${ROCKSDB_PATH}.tar.gz
ROCKSDB_LIBA=${ROCKSDB_PATH}/librocksdb.a
Expand All @@ -70,10 +70,6 @@ ZOOKEEPER_FILE=${ZOOKEEPER_PATH}.tar.gz
ZOOKEEPER_LIBA=${ZOOKEEPER_PATH}/.libs/libzkst.a
ZOOKEEPER_LIBHTA=${ZOOKEEPER_PATH}/.libs/libhashtable.a

KCDB_VER=kyotocabinet-1.2.76
KCDB_PATH=${LIB_PATH}/${KCDB_VER}
KCDB_FILE=${KCDB_PATH}.tar.gz
KCDB_LIBA=${KCDB_PATH}/libkyotocabinet.a

LUA_VER=lua
LUA_PATH=${LIB_PATH}/${LUA_VER}
Expand Down Expand Up @@ -135,8 +131,7 @@ CORE_OBJECTS := db.o data_format.o hash.o kv.o lists.o logger.o sets.o \
$(UTIL_OBJECTS) $(CHANNEL_OBJECTS)

LEVELDB_ENGINE := engine/leveldb_engine.o
ROCKSDB_ENGINE := engine/rocksdb_engine.o
KCDB_ENGINE := engine/kyotocabinet_engine.o
ROCKSDB_ENGINE := engine/rocksdb_engine.o
LMDB_ENGINE := engine/lmdb_engine.o
TESTOBJ := ../test/ardb_test.o
SERVEROBJ := main.o
Expand All @@ -152,14 +147,6 @@ ifeq ($(storage_engine), leveldb)
INCS+=-I${LEVELDB_PATH}/include
LIBS:=${LEVELDB_LIBA} ${SNAPPY_LIBA} ${LIBS}
else
ifeq ($(storage_engine), kyotocabinet)
STORAGE_ENGINE_OBJ=${KCDB_ENGINE}
STORAGE_ENGINE=kyotocabinet ${STORAGE_ENGINE_OBJ}
INCS+=-I${KCDB_PATH}

LIBS:= ${KCDB_LIBA} ${SNAPPY_LIBA} ${LIBS} -lz
CXXFLAGS+=-D__USE_KYOTOCABINET__
else
ifeq ($(storage_engine), lmdb)
STORAGE_ENGINE_OBJ=${LMDB_ENGINE}
STORAGE_ENGINE=lmdb ${STORAGE_ENGINE_OBJ}
Expand All @@ -178,7 +165,6 @@ else
endif
endif
endif
endif


all: test server
Expand Down Expand Up @@ -214,14 +200,6 @@ snappy:
./configure;make libsnappy.la;\
fi

kyotocabinet:
@if test -f ${KCDB_LIBA}; then\
:; \
else \
cd ${LIB_PATH};tar zxvf ${KCDB_FILE};cd ${KCDB_PATH};\
./configure;make;\
fi

lmdb:
@if test -f ${LMDB_LIBA}; then\
:; \
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int Buffer::IndexOf(const void* data, size_t len, size_t start, size_t end)
{
char *start_at = m_buffer + start_idx;
char* p = (char *) memchr(start_at, first, end - start_idx);
if (p)
if (p && (p + len - 1) < (m_buffer + end))
{
//start_idx.pos += p - start_at;
start_idx += (p - start_at);
Expand Down
2 changes: 1 addition & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define CONSTANTS_HPP_

#ifndef ARDB_VERSION
#define ARDB_VERSION "0.7.0"
#define ARDB_VERSION "0.7.2"
#endif

#define ARDB_FORMAT_VERSION 1
Expand Down
7 changes: 4 additions & 3 deletions src/engine/leveldb_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ namespace ardb
ParseConfig(props, m_cfg);
}


void LevelDBEngineFactory::ParseConfig(const Properties& props, LevelDBConfig& cfg)
{
cfg.path = ".";
Expand All @@ -69,6 +68,7 @@ namespace ardb
conf_get_int64(props, "leveldb.block_restart_interval", cfg.block_restart_interval);
conf_get_int64(props, "leveldb.bloom_bits", cfg.bloom_bits);
conf_get_int64(props, "leveldb.batch_commit_watermark", cfg.batch_commit_watermark);
conf_get_string(props, "leveldb.compression", cfg.compression);
}

KeyValueEngine* LevelDBEngineFactory::CreateDB(const std::string& name)
Expand Down Expand Up @@ -170,10 +170,11 @@ namespace ardb
{
m_options.filter_policy = leveldb::NewBloomFilterPolicy(cfg.bloom_bits);
}
if(!strcasecmp(cfg.compression.c_str(), "none"))
if (!strcasecmp(cfg.compression.c_str(), "none"))
{
m_options.compression = leveldb::kNoCompression;
}else
}
else
{
m_options.compression = leveldb::kSnappyCompression;
}
Expand Down
Loading

0 comments on commit 13921f0

Please sign in to comment.