Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ option(HAVE_STATS "stats enabled by default" ON)

option(TARGET_PINGSERVER "build pingserver binary" ON)
option(TARGET_DS "build dataserver binary" ON)
option(TARGET_SLIMDS "build slim dataserver binary" ON)
option(TARGET_SLIMDS "build slim dataserver binary" OFF)
option(TARGET_SLIMCACHE "build slimcache binary" ON)
option(TARGET_TWEMCACHE "build twemcache binary" ON)
option(TARGET_CDB "build cdb binary (implies HAVE_RUST)" OFF)
Expand All @@ -47,7 +47,6 @@ option(TARGET_RESPCLI "build resp-cli binary" ON)
option(HAVE_RUST "build features written in rust" OFF)
option(RUST_USE_MUSL "build rust deps against musl" OFF)
option(BUILD_AND_INSTALL_CHECK "build our own version of check and link against it" OFF)
option(USE_PMEM "build persistent memory features" OFF)

option(COVERAGE "code coverage" OFF)

Expand Down Expand Up @@ -140,24 +139,16 @@ add_subdirectory(${CCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/ccommon)
include(FindPackageHandleStandardArgs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

find_package(PkgConfig QUIET)

if(PKG_CONFIG_FOUND)
pkg_check_modules(CHECK QUIET check>=0.10)
endif()

find_package(Check)
if(NOT CHECK_FOUND)
find_package(Check QUIET 0.10)
endif()

if (USE_PMEM)
if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBPMEM REQUIRED libpmem>=1.0)
else()
find_package(LIBPMEM REQUIRED 1.0)
endif()
link_directories(${LIBPMEM_LIBRARY_DIRS})
endif(USE_PMEM)
message(WARNING "Check is required to build and run tests")
endif(NOT CHECK_FOUND)
if(CHECK_FOUND)
check_symbol_exists(ck_assert_int_eq check.h CHECK_WORKING)
if(NOT CHECK_WORKING)
message(WARNING "Check version too old to build tests")
endif(NOT CHECK_WORKING)
endif(CHECK_FOUND)

find_package(Threads)

Expand All @@ -177,11 +168,11 @@ include_directories(${include_directories}
# server & (cli) client
add_subdirectory(src)

# tests: always build last
if(CHECK_FOUND)
include_directories(${include_directories} ${CHECK_INCLUDES})
add_subdirectory(test)
endif(CHECK_FOUND)
## tests: always build last
#if(CHECK_WORKING)
# include_directories(${include_directories} "${CHECK_INCLUDES}")
# add_subdirectory(test)
#endif(CHECK_WORKING)

add_subdirectory(benchmarks)

Expand Down
19 changes: 10 additions & 9 deletions deps/ccommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,16 @@ endif(COVERAGE)
include(FindPackageHandleStandardArgs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

find_package(PkgConfig QUIET)

if(PKG_CONFIG_FOUND)
pkg_check_modules(CHECK QUIET check>=0.10)
endif()

find_package(Check)
if(NOT CHECK_FOUND)
find_package(Check QUIET 0.10)
endif()
message(WARNING "Check is required to build and run tests")
endif(NOT CHECK_FOUND)
if(CHECK_FOUND)
check_symbol_exists(ck_assert_int_eq check.h CHECK_WORKING)
if(NOT CHECK_WORKING)
message(WARNING "Check version too old to build tests")
endif(NOT CHECK_WORKING)
endif(CHECK_FOUND)

find_package(Threads)

Expand Down Expand Up @@ -208,4 +209,4 @@ message(STATUS "HAVE_SIGNAME: " ${HAVE_SIGNAME})

message(STATUS "HAVE_BACKTRACE: " ${HAVE_BACKTRACE})

message(STATUS "CHECK_FOUND: " ${CHECK_FOUND})
message(STATUS "CHECK_WORKING: " ${CHECK_WORKING})
2 changes: 1 addition & 1 deletion src/datapool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(datapool datapool.h)
add_library(datapool)

if(USE_PMEM)
target_sources(datapool PRIVATE datapool_pmem.c)
Expand Down
1 change: 1 addition & 0 deletions src/server/slimcache/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(SOURCE
set(MODULES
core
cuckoo
datapool
hotkey
protocol_admin
protocol_memcache
Expand Down
51 changes: 51 additions & 0 deletions src/server/slimcache/data/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cc_array.h>
#include <cc_debug.h>
#include <cc_print.h>
#include <time/cc_timer.h>

#define SLIMCACHE_PROCESS_MODULE_NAME "slimcache::process"

Expand All @@ -17,6 +18,48 @@
static bool process_init = false;
static process_metrics_st *process_metrics = NULL;
static bool allow_flush = ALLOW_FLUSH;
static bool prefill = PREFILL;
static uint8_t prefill_ksize;
static char prefill_kbuf[UINT8_MAX]; /* cuckoo storage has klen as uint8_t */
static uint8_t prefill_vsize;
static char prefill_vbuf[UINT8_MAX]; /* cuckoo storage has vlen as uint8_t */
static uint64_t prefill_nkey;


static void
_prefill_cuckoo(void)
{
struct duration d;
struct bstring key, vstr;
struct val val;
struct item *it;

duration_reset(&d);
key.len = prefill_ksize;
key.data = prefill_kbuf;
vstr.len = prefill_vsize;
vstr.data = prefill_vbuf;
val.type = VAL_TYPE_STR;
val.vstr = vstr;

duration_start(&d);
for (uint32_t i = 0; i < prefill_nkey; ++i) {
/* print fixed-length key with leading 0's for padding */
cc_snprintf(&prefill_kbuf, key.len + 1, "%.*d", key.len, i);
/* fill val, use the same value as key for now */
cc_snprintf(&prefill_vbuf, vstr.len + 1, "%.*d", vstr.len, i);
/* insert into cuckoo/heap */
it = cuckoo_insert(&key, &val,
time_convert_proc_sec((time_i)INT32_MAX));
ASSERT(it != NULL);
}
duration_stop(&d);

log_info("prefilling cuckoo with %"PRIu64" keys, of key len %"PRIu8" & val "
"len %"PRIu8", in %.3f seconds", prefill_nkey, prefill_ksize,
prefill_vsize, duration_sec(&d));
}


void
process_setup(process_options_st *options, process_metrics_st *metrics)
Expand All @@ -31,6 +74,14 @@ process_setup(process_options_st *options, process_metrics_st *metrics)

if (options != NULL) {
allow_flush = option_bool(&options->allow_flush);
prefill = option_bool(&options->prefill);
prefill_ksize = (uint8_t)option_uint(&options->prefill_ksize);
prefill_vsize = (uint8_t)option_uint(&options->prefill_vsize);
prefill_nkey = (uint64_t)option_uint(&options->prefill_nkey);
}

if (prefill) {
_prefill_cuckoo();
}

process_init = true;
Expand Down
19 changes: 18 additions & 1 deletion src/server/slimcache/data/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@
#include <stream/cc_sockio.h>

#define ALLOW_FLUSH false
#define PREFILL false
#define PREFILL_KSIZE 32
#define PREFILL_VSIZE 32
#define PREFILL_NKEY 600000000 /* 60M keys roughly fills up a 4GB heap with default data sizes */


/* name type default description */
#define PROCESS_OPTION(ACTION) \
ACTION( allow_flush, OPTION_TYPE_BOOL, ALLOW_FLUSH, "allow flushing on the data port" )
ACTION( allow_flush, OPTION_TYPE_BOOL, ALLOW_FLUSH, "allow flushing on the data port" )\
ACTION( prefill, OPTION_TYPE_BOOL, PREFILL, "prefill data array" )\
ACTION( prefill_ksize, OPTION_TYPE_UINT, PREFILL_KSIZE, "prefill key size" )\
ACTION( prefill_vsize, OPTION_TYPE_UINT, PREFILL_VSIZE, "prefill val size" )\
ACTION( prefill_nkey, OPTION_TYPE_UINT, PREFILL_NKEY, "prefill keys inserted" )
/* For now, the prefill logic will populate the heap with keys and values of
* specified lengths, while the keys will be string representation of base-10
* numeric values padded to the right length, i.e. keys will look like
* "000000", "000001", ..., "123456", and prefilling logic will always start
* from 0 and trying to insert the exact number of keys specified (underfill
* and eviction are therefore possible) depending on how cuckoo array is
* configured.
*/

typedef struct {
PROCESS_OPTION(OPTION_DECLARE)
Expand Down
1 change: 1 addition & 0 deletions src/server/slimds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(SOURCE

set(MODULES
core
datatool
cuckoo
ds_bitmap
protocol_admin
Expand Down
8 changes: 4 additions & 4 deletions src/server/twemcache/data/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ static bool process_init = false;
static process_metrics_st *process_metrics = NULL;
static bool allow_flush = ALLOW_FLUSH;
static bool prefill = PREFILL;
static uint32_t prefill_ksize;
static char prefill_kbuf[UINT8_MAX]; /* slab implementation has klen as unint8_t */
static uint8_t prefill_ksize;
static char prefill_kbuf[UINT8_MAX]; /* slab implementation has klen as uint8_t */
static uint32_t prefill_vsize;
/* val_buf size is arbitrary , update if want to warm up with larger objects */
static char prefill_vbuf[ITEM_SIZE_MAX];
Expand Down Expand Up @@ -63,7 +63,7 @@ _prefill_slab(void)
}
duration_stop(&d);

log_info("prefilling slab with %"PRIu64" keys, of key len %"PRIu32" & val "
log_info("prefilling slab with %"PRIu64" keys, of key len %"PRIu8" & val "
"len %"PRIu32", in %.3f seconds", prefill_nkey, prefill_ksize,
prefill_vsize, duration_sec(&d));
}
Expand All @@ -83,7 +83,7 @@ process_setup(process_options_st *options, process_metrics_st *metrics)
if (options != NULL) {
allow_flush = option_bool(&options->allow_flush);
prefill = option_bool(&options->prefill);
prefill_ksize = (uint32_t)option_uint(&options->prefill_ksize);
prefill_ksize = (uint8_t)option_uint(&options->prefill_ksize);
prefill_vsize = (uint32_t)option_uint(&options->prefill_vsize);
prefill_nkey = (uint64_t)option_uint(&options->prefill_nkey);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/twemcache/data/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/* name type default description */
#define PROCESS_OPTION(ACTION) \
ACTION( allow_flush, OPTION_TYPE_BOOL, ALLOW_FLUSH, "allow flush_all" )\
ACTION( allow_flush, OPTION_TYPE_BOOL, ALLOW_FLUSH, "allow flush on data port")\
ACTION( prefill, OPTION_TYPE_BOOL, PREFILL, "prefill slabs with data" )\
ACTION( prefill_ksize, OPTION_TYPE_UINT, PREFILL_KSIZE, "prefill key size" )\
ACTION( prefill_vsize, OPTION_TYPE_UINT, PREFILL_VSIZE, "prefill val size" )\
Expand Down
1 change: 0 additions & 1 deletion src/storage/cuckoo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
add_library(cuckoo cuckoo.c)
target_link_libraries(cuckoo datapool)