Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge PMDK to Master #7

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f0e2205
Initial pmdk pushes for clht_lb_res
pyrito Mar 6, 2020
8aaf5c2
Refactored & bug
pyrito Mar 13, 2020
922b912
Fixed seg fault
pyrito Mar 14, 2020
1d56564
Main logic working with PMDK
pyrito Mar 15, 2020
1982610
Implemented PM clean-up, solved segfault
pyrito Mar 16, 2020
298bf59
Modified clean-up in clht_gc.c, found resizing bug
pyrito Mar 17, 2020
6a5a4d4
Fixed PMEMpool size, still having segfault
pyrito Mar 17, 2020
b3ead0c
Solved seg fault for hashtable. WIP
pyrito Mar 19, 2020
b859a6b
Replicated bug
pyrito Mar 19, 2020
5ec9a47
Fixed seg fault, still issue with ssmem
pyrito Mar 21, 2020
2e07aca
Changed clht_open func param
pyrito Mar 21, 2020
fd33b64
First implementation of transactions
pyrito Mar 23, 2020
824f5e2
Trimmed use of transactions. WIP.
pyrito Mar 31, 2020
bd951e6
Working on cache alignment fix. WIP.
pyrito Apr 1, 2020
9b605d9
Cache-line alignment fixed.
pyrito Apr 1, 2020
5dda496
Added README information for PMDK
pyrito Apr 5, 2020
bbdd250
Added transaction configurability
pyrito Apr 6, 2020
f4243fe
Documentation changes
pyrito Apr 8, 2020
03c7b32
Merge branch 'master' into pmdk
SeKwonLee Apr 9, 2020
fb11b10
Initial commit applying PMDK to masstree
SeKwonLee Apr 10, 2020
9782868
Integrated correct transactions
pyrito Apr 11, 2020
4f6a839
Merge branch 'pmdk' of https://github.com/utsaslab/RECIPE into pmdk
pyrito Apr 11, 2020
77bc50d
[P-Masstree] Update compile options and minor changes
Apr 12, 2020
c8182e3
Update pmdk document
SeKwonLee Apr 12, 2020
1ec6380
[P-CLHT] update compile options
SeKwonLee Apr 12, 2020
3d82a49
Fixed bug in clht_lb_res.c
pyrito Apr 12, 2020
af8106d
Merge branch 'master' into pmdk
SeKwonLee Apr 14, 2020
ed00f17
:sparkles: add the new feature to reload masstree
SeKwonLee Apr 14, 2020
0405b2d
Merge branch 'master' into pmdk
SeKwonLee Apr 15, 2020
8d3b00a
Merge branch 'master' into pmdk
SeKwonLee Apr 15, 2020
270bb09
Exchange free to pmemobj_free
SeKwonLee Apr 15, 2020
3514403
Added some previously deleted code
pyrito Apr 16, 2020
7006004
Merge branch 'pmdk' of https://github.com/utsaslab/RECIPE into pmdk
pyrito Apr 16, 2020
8d7af8a
Integrate clht_open to clht_create
SeKwonLee Apr 16, 2020
d495e35
Remove comments related to DIMM
SeKwonLee Apr 16, 2020
058e0b1
Merge branch 'master' into pmdk
SeKwonLee Apr 18, 2020
03af92d
Modified README for P-CLHT
pyrito Apr 18, 2020
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
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.associations": {
"mutex": "c",
"shared_mutex": "c",
"condition_variable": "c",
"chrono": "cpp"
}
}
10 changes: 9 additions & 1 deletion P-CLHT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ find_library(JemallocLib jemalloc)
find_library(TbbLib tbb)
find_package (Threads)

if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++)
else()
find_package(LIBPMEMOBJ++ REQUIRED)
endif()

link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS})

set(P_CLHT_TEST example.cpp src/clht_lb_res.c src/clht_gc.c
external/sspfd/sspfd.c external/ssmem/src/ssmem.c)
add_executable(example ${P_CLHT_TEST})

target_link_libraries(example ${TbbLib} ${JemallocLib} boost_system
target_link_libraries(example ${TbbLib} ${JemallocLib} ${LIBPMEMOBJ++_LIBRARIES} boost_system
boost_thread pthread)
2 changes: 1 addition & 1 deletion P-CLHT/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ CFLAGS += $(PLATFORM)
CFLAGS += $(OPTIMIZE)
CFLAGS += $(DEBUG_FLAGS)

INCLUDES := -I$(MAININCLUDE) -I$(TOP)/external/include
INCLUDES := -I$(MAININCLUDE) -I$(TOP)/external/include
OBJ_FILES := clht_gc.o

SRC := src
Expand Down
16 changes: 9 additions & 7 deletions P-CLHT/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <atomic>
#include "tbb/tbb.h"

using namespace std;
#include <libpmemobj.h>

#include "clht.h"
#include "clht_lb_res.h"
#include "ssmem.h"

typedef struct thread_data {
Expand Down Expand Up @@ -117,11 +117,13 @@ void run(char **argv) {
barrier_cross(&barrier);

for (uint64_t i = start_key; i < end_key; i++) {
uintptr_t val = clht_get(tds[thread_id].ht->ht, keys[i]);
if (val != keys[i]) {
std::cout << "[CLHT] wrong key read: " << val << "expected: " << keys[i] << std::endl;
exit(1);
}
PMEMoid pmem_ht = (PMEMoid)((tds[thread_id].ht)->ht);
clht_hashtable_t *ht = (clht_hashtable_t*)pmemobj_direct(pmem_ht);
uintptr_t val = clht_get(ht, keys[i]);
if (val != keys[i]) {
std::cout << "[CLHT] wrong key read: " << val << "expected: " << keys[i] << std::endl;
exit(1);
}
}
};

Expand Down
20 changes: 17 additions & 3 deletions P-CLHT/include/clht_lb_res.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <inttypes.h>
#include "atomic_ops.h"
#include "utils.h"
#include <libpmemobj.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -160,7 +161,8 @@ typedef struct ALIGNED(CACHE_LINE_SIZE) bucket_s
volatile uint32_t hops;
clht_addr_t key[ENTRIES_PER_BUCKET];
clht_val_t val[ENTRIES_PER_BUCKET];
volatile struct bucket_s* next;
// volatile struct bucket_s* next;
PMEMoid next;
} bucket_t;

//#if __GNUC__ > 4 && __GNUC_MINOR__ > 4
Expand All @@ -173,8 +175,10 @@ typedef struct ALIGNED(CACHE_LINE_SIZE) clht
{
struct
{
struct clht_hashtable_s* ht;
PMEMoid ht;
// struct clht_hashtable_s* ht;
uint8_t next_cache_line[CACHE_LINE_SIZE - (sizeof(void*))];
// Prob need to add TOID to this as well
struct clht_hashtable_s* ht_oldest;
struct ht_ts* version_list;
size_t version_min;
Expand All @@ -193,7 +197,8 @@ typedef struct ALIGNED(CACHE_LINE_SIZE) clht_hashtable_s
struct
{
size_t num_buckets;
bucket_t* table;
PMEMoid table;
//bucket_t* table;
size_t hash;
size_t version;
uint8_t next_cache_line[CACHE_LINE_SIZE - (3 * sizeof(size_t)) - (sizeof(void*))];
Expand Down Expand Up @@ -405,6 +410,7 @@ lock_acq_rtm_chk_resize(clht_lock_t* lock, clht_hashtable_t* h)
/* Create a new hashtable. */
clht_hashtable_t* clht_hashtable_create(uint64_t num_buckets);
clht_t* clht_create(uint64_t num_buckets);
clht_t* clht_open();

/* Insert a key-value pair into a hashtable. */
int clht_put(clht_t* hashtable, clht_addr_t key, clht_val_t val);
Expand Down Expand Up @@ -441,6 +447,14 @@ int ht_resize_pes(clht_t* hashtable, int is_increase, int by);
const char* clht_type_desc();

void clht_lock_initialization(clht_t *h);

// Initialize the persistent memory pool
POBJ_LAYOUT_BEGIN(clht);
POBJ_LAYOUT_ROOT(clht, clht_t);
POBJ_LAYOUT_TOID(clht, clht_hashtable_t);
POBJ_LAYOUT_TOID(clht, bucket_t);
POBJ_LAYOUT_END(clht);

#ifdef __cplusplus
}
#endif
Expand Down
61 changes: 37 additions & 24 deletions P-CLHT/src/clht_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ clht_gc_thread_init(clht_t* h, int id)
ht_ts_t* ts = (ht_ts_t*) memalign(CACHE_LINE_SIZE, sizeof(ht_ts_t));
assert(ts != NULL);

ts->version = h->ht->version;
clht_hashtable_t* ht_ptr = pmemobj_direct(h->ht);
ts->version = ht_ptr->version;
ts->id = id;

do
Expand Down Expand Up @@ -128,7 +129,8 @@ clht_gc_min_version_used(clht_t* h)
{
volatile ht_ts_t* cur = h->version_list;

size_t min = h->ht->version;
clht_hashtable_t* ht_ptr = pmemobj_direct(h->ht);
size_t min = ht_ptr->version;
while (cur != NULL)
{
if (cur->version < min)
Expand All @@ -149,8 +151,9 @@ clht_gc_min_version_used(clht_t* h)
static int
clht_gc_collect_cond(clht_t* hashtable, int collect_not_referenced_only)
{
clht_hashtable_t* ht_ptr = pmemobj_direct(hashtable->ht);
/* if version_min >= current version there is nothing to collect! */
if ((hashtable->version_min >= hashtable->ht->version) || TRYLOCK_ACQ(&hashtable->gc_lock))
if ((hashtable->version_min >= ht_ptr->version) || TRYLOCK_ACQ(&hashtable->gc_lock))
{
/* printf("** someone else is performing gc\n"); */
return 0;
Expand All @@ -160,7 +163,7 @@ clht_gc_collect_cond(clht_t* hashtable, int collect_not_referenced_only)

/* printf("[GCOLLE-%02d] LOCK : %zu\n", GET_ID(collect_not_referenced_only), hashtable->version); */

size_t version_min = hashtable->ht->version;
size_t version_min = ht_ptr->version;
if (collect_not_referenced_only)
{
version_min = clht_gc_min_version_used(hashtable);
Expand Down Expand Up @@ -221,20 +224,23 @@ clht_gc_free(clht_hashtable_t* hashtable)
uint64_t bin;
for (bin = 0; bin < num_buckets; bin++)
{
bucket = hashtable->table + bin;
bucket = bucket->next;
bucket = ((bucket_t*)pmemobj_direct(hashtable->table)) + bin;
bucket = pmemobj_direct(bucket->next);

while (bucket != NULL)
{
volatile bucket_t* cur = bucket;
bucket = bucket->next;
free((void*) cur);
}
{
volatile bucket_t* cur = bucket;
bucket = pmemobj_direct(bucket->next);
PMEMoid cur_oid = pmemobj_oid((void*) cur);
pmemobj_free(&cur_oid);
}
}
#endif

free(hashtable->table);
free(hashtable);

pmemobj_free(&(hashtable->table));
PMEMoid ht_oid = pmemobj_oid((void*) hashtable);
pmemobj_free(&ht_oid);

return 1;
}

Expand All @@ -246,12 +252,13 @@ clht_gc_destroy(clht_t* hashtable)
{
#if !defined(CLHT_LINKED)
clht_gc_collect_all(hashtable);
clht_gc_free(hashtable->ht);
free(hashtable);
clht_gc_free(pmemobj_direct(hashtable->ht));
// PMEMoid ht_oid = pmemobj_oid((void*) hashtable);
// pmemobj_free(&ht_oid);
#endif

// ssmem_alloc_term(clht_alloc);
free(clht_alloc);
// ssmem_alloc_term(clht_alloc);
//free(clht_alloc);
}

/*
Expand All @@ -269,20 +276,26 @@ clht_gc_release(clht_hashtable_t* hashtable)

uint64_t bin;
for (bin = 0; bin < num_buckets; bin++)
{
bucket = hashtable->table + bin;
bucket = bucket->next;
{
bucket = ((bucket_t*)pmemobj_direct(hashtable->table)) + bin;
bucket = pmemobj_direct(bucket->next);

while (bucket != NULL)
{
volatile bucket_t* cur = bucket;
bucket = bucket->next;
bucket = pmemobj_direct(bucket->next);
ssmem_release(clht_alloc, (void*) cur);
// PMEMoid cur_oid = pmemobj_oid((void*) cur);
// pmemobj_free(&cur_oid);
}
}
}
#endif

ssmem_release(clht_alloc, hashtable->table);
ssmem_release(clht_alloc, pmemobj_direct(hashtable->table));
ssmem_release(clht_alloc, hashtable);
// pmemobj_free(&(hashtable->table));
// PMEMoid ht_oid = pmemobj_oid((void*) hashtable);
// pmemobj_free(&ht_oid);
return 1;
}

Expand Down
Loading