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
3 changes: 3 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ set(DS_DIR "ds")
set(BUILD_DIR "bin/")
set(RECLAIM ".debra")

# Flag for key type usage
add_definitions("-DUSE_LONG_LONG")

#set(SOURCE_EXE main.cpp)
#set(CMAKE_CXX_FLAGS "-lpthread -ldl -mrtm")
list(APPEND CMAKE_CXX_FLAGS_LIST "-lpthread -ldl -mrtm ")
Expand Down
22 changes: 22 additions & 0 deletions cpp/microbench/global_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef GLOBAL_TYPES_H
#define GLOBAL_TYPES_H

#ifdef REDIS
typedef KEY_TYPE VALUE_TYPE;
#else
typedef void * VALUE_TYPE;
#endif

#ifdef USE_STRING
#define KEY_TYPE std::string
#endif

#ifdef USE_LONG_LONG
#define KEY_TYPE long long
#endif

#ifndef KEY_TYPE
#define KEY_TYPE long long
#endif

#endif //SETBENCH_GLOBALS_T_H
1 change: 1 addition & 0 deletions cpp/microbench/globals_extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//#define USE_TRACE

#include <string>
#include "global_types.h"

#ifdef MAIN_BENCH

Expand Down
6 changes: 2 additions & 4 deletions cpp/microbench/globals_t.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
//
// Created by Ravil Galiev on 26.07.2023.
//

#ifndef SETBENCH_GLOBALS_T_H
#define SETBENCH_GLOBALS_T_H

typedef long long test_type;
#include "global_types.h"

#ifdef REDIS
#define VALUE_TYPE test_type
#define KEY_TO_VALUE(key) key
#define GET_FUNC executeContains
#else
#define VALUE_TYPE void *
#define KEY_TO_VALUE(key) &key /* note: hack to turn a key into a pointer */
#define GET_FUNC executeGet
#endif

#define DS_ADAPTER_T ds_adapter<test_type, VALUE_TYPE, RECLAIM<>, ALLOC<>, POOL<> >
#define DS_ADAPTER_T ds_adapter<KEY_TYPE, VALUE_TYPE, RECLAIM<>, ALLOC<>, POOL<> >
Comment on lines -8 to +18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так может все это в целом перенести в global types? зачем размазывать по разным файлам


struct globals_t;

Expand Down
14 changes: 8 additions & 6 deletions cpp/microbench/globals_t_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef SETBENCH_GLOBALS_T_IMPL_H
#define SETBENCH_GLOBALS_T_IMPL_H

typedef long long test_type;
// typedef long long test_type;

//#ifdef REDIS
// #define VALUE_TYPE test_type
Expand All @@ -32,8 +32,8 @@ struct globals_t {
// const
// void *const NO_VALUE;
VALUE_TYPE const NO_VALUE;
const test_type KEY_MIN; // must be smaller than any key that can be inserted/deleted
const test_type KEY_MAX; // must be less than std::max(), because the snap collector needs a reserved key larger than this! (and larger than any key that can be inserted/deleted)
const KEY_TYPE KEY_MIN; // must be smaller than any key that can be inserted/deleted
const KEY_TYPE KEY_MAX; // must be less than std::max(), because the snap collector needs a reserved key larger than this! (and larger than any key that can be inserted/deleted)
const long long PREFILL_INTERVAL_MILLIS;
PAD;
// write once
Expand All @@ -48,7 +48,7 @@ struct globals_t {
PAD;
long elapsedMillisNapping;
PAD;
volatile test_type garbage; // used to prevent optimizing out some code
volatile long long garbage; // used to prevent optimizing out some code
Comment thread
Altickium marked this conversation as resolved.
PAD;
DS_ADAPTER_T *dsAdapter; // the data structure
PAD;
Expand All @@ -66,8 +66,10 @@ struct globals_t {
PAD;

globals_t(BenchParameters * _benchParameters)
: NO_VALUE(NULL), KEY_MIN(0) /*std::numeric_limits<test_type>::min()+1)*/
, KEY_MAX(_benchParameters->range + 1), PREFILL_INTERVAL_MILLIS(200),
: NO_VALUE(NULL)
, KEY_MIN(_benchParameters->dataMap->get_min()) /*std::numeric_limits<test_type>::min()+1)*/
, KEY_MAX(_benchParameters->dataMap->get_max(_benchParameters->range + 1))
, PREFILL_INTERVAL_MILLIS(200),
benchParameters(_benchParameters) {
debug_print = 0;
srand(time(0));
Expand Down
8 changes: 4 additions & 4 deletions cpp/microbench/json_example/creakers_and_wave_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"argsGeneratorBuilder": {
"ClassName": "CreakersAndWavePrefillArgsGeneratorBuilder",
"creakersSize": 0.1,
"dataMapBuilder": {
"ClassName": "IdDataMapBuilder",
"indexMapBuilder": {
"ClassName": "IdIndexMapBuilder",
"id": 1
},
"waveSize": 0.2
Expand Down Expand Up @@ -53,8 +53,8 @@
},
"creakersRatio": 0.2,
"creakersSize": 0.1,
"dataMapBuilder": {
"ClassName": "IdDataMapBuilder",
"indexMapBuilder": {
"ClassName": "IdIndexMapBuilder",
"id": 1
},
"waveDistBuilder": {
Expand Down
9 changes: 5 additions & 4 deletions cpp/microbench/json_example/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ClassName": "PrefillInsertThreadLoopBuilder",
"argsGeneratorBuilder": {
"ClassName": "DefaultArgsGeneratorBuilder",
"dataMapBuilder": {
"ClassName": "IdDataMapBuilder",
"indexMapBuilder": {
"ClassName": "IdIndexMapBuilder",
"id": 4
},
"distributionBuilder": {
Expand All @@ -26,6 +26,7 @@
]
},
"range": 2048,
"dataMap": "IntDataMap",
"test": {
"numThreads": 8,
"stopCondition": {
Expand All @@ -40,8 +41,8 @@
"ClassName": "DefaultThreadLoopBuilder",
"argsGeneratorBuilder": {
"ClassName": "DefaultArgsGeneratorBuilder",
"dataMapBuilder": {
"ClassName": "ArrayDataMapBuilder",
"indexMapBuilder": {
"ClassName": "ArrayIndexMapBuilder",
"id": 1
},
"distributionBuilder": {
Expand Down
8 changes: 4 additions & 4 deletions cpp/microbench/json_example/generalized_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ClassName": "PrefillInsertThreadLoopBuilder",
"argsGeneratorBuilder": {
"ClassName": "DefaultArgsGeneratorBuilder",
"dataMapBuilder": {
"ClassName": "IdDataMapBuilder",
"indexMapBuilder": {
"ClassName": "IdIndexMapBuilder",
"id": 4
},
"distributionBuilder": {
Expand Down Expand Up @@ -54,8 +54,8 @@
"opers": ["get", "insert", "remove"],
"argsGeneratorBuilder": {
"ClassName": "DefaultArgsGeneratorBuilder",
"dataMapBuilder": {
"ClassName": "ArrayDataMapBuilder",
"indexMapBuilder": {
"ClassName": "ArrayIndexMapBuilder",
"id": 1
},
"distributionBuilder": {
Expand Down
8 changes: 4 additions & 4 deletions cpp/microbench/json_example/json_example.cpp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

было бы ещё неплохо добавить пример с DataMap

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef long long ll;
ArgsGeneratorBuilder* getDefaultArgsGeneratorBuilder() {
return (new DefaultArgsGeneratorBuilder())
->setDistributionBuilder((new ZipfianDistributionBuilder())->setAlpha(1.0))
->setDataMapBuilder(new ArrayDataMapBuilder());
->setIndexMapBuilder(new ArrayIndexMapBuilder());
}

ArgsGeneratorBuilder* getTemporarySkewedArgsGeneratorBuilder() {
Expand All @@ -43,7 +43,7 @@ ArgsGeneratorBuilder* getCreakersAndWaveArgsGeneratorBuilder() {
->setCreakersRatio(0.2)
->setWaveSize(0.2)
->setCreakersSize(0.1)
->setDataMapBuilder(new IdDataMapBuilder());
->setIndexMapBuilder(new IdIndexMapBuilder());
}

ArgsGeneratorBuilder* getNullArgsGeneratorBuilder() {
Expand All @@ -53,7 +53,7 @@ ArgsGeneratorBuilder* getNullArgsGeneratorBuilder() {
ArgsGeneratorBuilder* getRangeQueryArgsGeneratorBuilder() {
return (new RangeQueryArgsGeneratorBuilder())
->setDistributionBuilder((new ZipfianDistributionBuilder())->setAlpha(1.0))
->setDataMapBuilder(new ArrayDataMapBuilder())
->setIndexMapBuilder(new ArrayIndexMapBuilder())
->setInterval(100);
}

Expand All @@ -65,7 +65,7 @@ ArgsGeneratorBuilder* getGeneralizedArgsGeneratorBuilder(ArgsGeneratorBuilder* i
->addArgsGeneratorBuilder({"remove"}, getDefaultArgsGeneratorBuilder())
->addArgsGeneratorBuilder({"rangeQuery"}, getRangeQueryArgsGeneratorBuilder());
// ->setDistributionBuilder((new ZipfianDistributionBuilder())->setAlpha(1.0))
// ->setDataMapBuilder(new ArrayDataMapBuilder()));
// ->setIndexMapBuilder(new ArrayIndexMapBuilder()));
}

ThreadLoopBuilder* getDefaultThreadLoopBuilder(ArgsGeneratorBuilder* argsGeneratorBuilder) {
Expand Down
Loading