 |
NVMLib
very early alpha
A library to optimally use a Hybrid RAM setup.
|
Go to the documentation of this file.
4 #include <libpmemobj.h>
35 printf(
"%ld -- num_read %ld , num_writes %ld",
entry->
key,
entry->num_reads,
entry->num_writes);
97 pthread_t logistics_thread, deletion_thread;
99 uv_loop_t *logistics_loop = uv_loop_new();
102 uv_loop_t *deletion_loop = uv_loop_new();
115 uv_loop_t *thread_loop = (uv_loop_t *) data;
116 LOG_INFO(
"Logistics thread will start event loop\n");
118 uv_timer_t timer_logistics;
119 uv_timer_init(thread_loop, &timer_logistics);
123 uv_run(thread_loop, UV_RUN_DEFAULT);
136 uv_loop_t *thread_loop = (uv_loop_t *) data;
137 LOG_INFO(
"Deletion thread will start event loop\n");
139 uv_timer_t timer_logistics;
140 uv_timer_init(thread_loop, &timer_logistics);
144 uv_run(thread_loop, UV_RUN_DEFAULT);
149 int byteno = offset/64;
150 int shift = offset%64;
153 for (
int i = 0; i < size; i++) {
154 if (shift >= 64) {shift = 0; byteno++; bit = 1;}
155 bitmap[byteno] & bit?0:new_set++;
156 bitmap[byteno] |= bit;
186 if(!object_maintainance_map->entries){
192 while(!TAILQ_EMPTY(&addition_queue_head)) {
199 TAILQ_REMOVE(&addition_queue_head, to_add, list);
203 while(!TAILQ_EMPTY(&write_queue_head)) {
204 address_log* w_add = TAILQ_FIRST(&write_queue_head);
225 TAILQ_REMOVE(&write_queue_head, w_add, list);
227 while(!TAILQ_EMPTY(&read_queue_head)) {
228 address_log* r_add = TAILQ_FIRST(&read_queue_head);
249 TAILQ_REMOVE(&read_queue_head, r_add, list);
257 for(
size_t i=0; i<object_maintainance_map->power_of_two; i++) {
259 for(
int j = 0; j < bucket->size; j++) {
261 var = bucket->entries[j];
267 work_req = (uv_work_t*)malloc(
sizeof(*work_req));
276 work_req = (uv_work_t*)malloc(
sizeof(*work_req));
301 if(!object_maintainance_map->entries){
308 while(!TAILQ_EMPTY(&deletion_queue_head)) {
313 TAILQ_REMOVE(&deletion_queue_head, to_delete, list);
361 size_t size = oid.
size;
362 bool is_dram =
false;
398 LOG_INFO(
"delete_object: %ld from %s at [%ld ms]\n", key, is_dram?
"DRAM":
"NVRAM", (uv_hrtime() / 1000000) % 100000);
417 size_t size = oid.
size;
451 new_maintainance_map_obj->
oid = new_obj;
460 LOG_INFO(
"move_to_dram: %ld at [%ld ms]\n", key, (uv_hrtime() / 1000000) % 100000);
481 size_t size = oid.
size;
518 new_maintainance_map_obj->
oid = new_obj;
527 LOG_INFO(
"move_to_nvram: %ld at [%ld ms]\n", key, (uv_hrtime() / 1000000) % 100000);
556 if (!
entry.can_be_moved) {
617 TAILQ_INIT(&addition_queue_head);
618 TAILQ_INIT(&deletion_queue_head);
uv_mutex_t write_splay_tree_mutex
The mutex used during manupulation of read splay tree
HASH_MAP(object_maintainance)
Hashmap for object maintaince.
void * logistics_thread_function(void *data)
The logistics thread function.
void initialise_logistics()
uv_mutex_t object_maintainence_maintain_map_mutex
The mutex used during manupulation of maintainance map
int compare(object_maintainance *a, object_maintainance *b)
uintptr_t get_pool_from_poolid(uint64_t pool_id)
void insert_object_to_hashmap(MEMoidKey key, MEMoid oid)
void delete_object(MEMoidKey key, MEMoid oid)
The function to delete the object specified.
DECLARE_HASHMAP(pool_free_slot_val)
int check_if_required_to_move(object_maintainance entry)
Checks if an object can be moved or not.
#define LOG_INFO(message, args...)
The struct that stores the memptr for the object.
shift_levels_t shift_level
#define HASH_MAP_BUCKET(VALUE_TYPE)
uint64_t MEMoidKey
The key of the HashTable that contains <MEMoidKey, MEMoid>.
uv_mutex_t read_splay_tree_mutex
The mutex used during manupulation of read splay tree
void move_to_dram(uv_work_t *req)
The function to move an object from NVRAM to DRAM.
MEMoid allot_first_free_offset(size_t size)
Allocates the first free memory chunk of the given size.
void * deletion_thread_function(void *data)
The deletion thread function.
void on_logistics_timer(uv_timer_t *timer, int status)
The function thats called when the logistic thread wakes up.
void remove_object_from_hashmap(MEMoidKey key)
#define HASH_MAP_ERASE(VALUE_TYPE)
object_maintainance * create_new_maintainance_map_entry(MEMoidKey key, MEMoid oid, where_t which_ram, bool can_be_moved)
void delete_from_maintainance_map(object_maintainance *obj)
#define MOVE_LOOP_SLEEP_TIME
object_maintainance * find_in_maintainance_map(MEMoidKey key)
#define HASH_MAP_INSERT(VALUE_TYPE)
int check_if_required_to_delete(object_maintainance entry)
void insert_into_maintainance_map(object_maintainance *obj)
uv_mutex_t object_maintainence_addtion_mutex
The mutex used during manupulation of maintainance map
void on_deletion_timer(uv_timer_t *timer, int status)
The function thats called when the deletion thread wakes up.
#define HASH_MAP_PRINT_FUNC(VALUE_TYPE, PRINT_OBJ_FUNC)
The structure used by the logistics thread for keeping track of the object state in order to make dif...
void create_addition_deletion_queues()
uv_mutex_t object_maintainence_deletion_mutex
The mutex used during manupulation of maintainance map
void on_after_work(uv_work_t *req, int status)
uv_mutex_t object_maintainence_memory_mutex
The mutex used during nvm_free / access too.
static size_t set_bits(uint64_t *bitmap, size_t offset, size_t size)
time_t time_since_previous_access
uv_mutex_t object_maintainence_hashmap_mutex
The mutex used during manupulation of types map
#define HASH_MAP_PRINT(VALUE_TYPE)
For Debug purposes.
#define HASH_MAP_CREATE(VALUE_TYPE)
#define DEFINE_HASHMAP(VALUE_TYPE, CMP, GET_HASH, FREE, REALLOC)
Definition of the declared HashMap.
#define POOL_ID_MALLOC_OBJ
void move_to_nvram(uv_work_t *req)
The function to move an object from DRAM to NVRAM.
#define HASH_MAP_FIND(VALUE_TYPE)
MEMoid get_MEMoid(MEMoidKey key)
The function to obtain the MEMoid object given the MEMoidKey
void nvm_free(uint64_t pool_id, uint64_t offset, size_t size)
void reset_om(object_maintainance *om)
uint64_t get_hash(object_maintainance *entry)
void create_maintainance_map()
access_types_t previous_access_type