NVMLib  very early alpha
A library to optimally use a Hybrid RAM setup.
object_maintainance.c File Reference
#include "object_maintainance.h"
#include "types.h"
#include "malloc.h"
#include <libpmemobj.h>
#include "globals.h"
#include "pool.h"
#include "hashmap.h"
#include "mem_log.h"
#include "log.h"
#include <uv.h>
#include <pthread.h>
Include dependency graph for object_maintainance.c:

Go to the source code of this file.

Functions

uint64_t get_hash (object_maintainance *entry)
 
int compare (object_maintainance *a, object_maintainance *b)
 
 HASH_MAP (object_maintainance)
 Hashmap for object maintaince. More...
 
void unlock_om ()
 
void initialise_logistics ()
 
void * logistics_thread_function (void *data)
 The logistics thread function. More...
 
void * deletion_thread_function (void *data)
 The deletion thread function. More...
 
static size_t set_bits (uint64_t *bitmap, size_t offset, size_t size)
 
void reset_om (object_maintainance *om)
 
void on_logistics_timer (uv_timer_t *timer, int status)
 The function thats called when the logistic thread wakes up. More...
 
void on_deletion_timer (uv_timer_t *timer, int status)
 The function thats called when the deletion thread wakes up. More...
 
void delete_object (MEMoidKey key, MEMoid oid)
 The function to delete the object specified. More...
 
void move_to_dram (uv_work_t *req)
 The function to move an object from NVRAM to DRAM. More...
 
void move_to_nvram (uv_work_t *req)
 The function to move an object from DRAM to NVRAM. More...
 
void on_after_work (uv_work_t *req, int status)
 
int check_if_required_to_delete (object_maintainance entry)
 
int check_if_required_to_move (object_maintainance entry)
 Checks if an object can be moved or not. More...
 
void create_maintainance_map ()
 
object_maintainancecreate_new_maintainance_map_entry (MEMoidKey key, MEMoid oid, where_t which_ram, bool can_be_moved)
 
void insert_into_maintainance_map (object_maintainance *obj)
 
void delete_from_maintainance_map (object_maintainance *obj)
 
object_maintainancefind_in_maintainance_map (MEMoidKey key)
 
void create_addition_deletion_queues ()
 

Variables

uv_mutex_t object_maintainence_hashmap_mutex
 The mutex used during manupulation of types map More...
 
uv_mutex_t object_maintainence_memory_mutex
 The mutex used during nvm_free / access too. More...
 
uv_mutex_t object_maintainence_maintain_map_mutex
 The mutex used during manupulation of maintainance map More...
 
uv_mutex_t object_maintainence_addtion_mutex
 The mutex used during manupulation of maintainance map More...
 
uv_mutex_t object_maintainence_deletion_mutex
 The mutex used during manupulation of maintainance map More...
 
uv_mutex_t read_splay_tree_mutex
 The mutex used during manupulation of read splay tree More...
 
uv_mutex_t write_splay_tree_mutex
 The mutex used during manupulation of read splay tree More...
 

Function Documentation

◆ check_if_required_to_delete()

int check_if_required_to_delete ( object_maintainance  entry)

Definition at line 541 of file object_maintainance.c.

◆ check_if_required_to_move()

int check_if_required_to_move ( object_maintainance  entry)

Checks if an object can be moved or not.

Parameters
entryThe entry of the object under analysis from the object maintainance table.
Returns
1: If needs to be moved from DRAM to NVRAM
2: If needs to be moved from NVRAM to DRAM
0: otherwise

Definition at line 554 of file object_maintainance.c.

◆ compare()

int compare ( object_maintainance a,
object_maintainance b 
)

Definition at line 26 of file object_maintainance.c.

◆ create_addition_deletion_queues()

void create_addition_deletion_queues ( )

Definition at line 616 of file object_maintainance.c.

◆ create_maintainance_map()

void create_maintainance_map ( )

Definition at line 566 of file object_maintainance.c.

◆ create_new_maintainance_map_entry()

object_maintainance* create_new_maintainance_map_entry ( MEMoidKey  key,
MEMoid  oid,
where_t  which_ram,
bool  can_be_moved 
)

Definition at line 570 of file object_maintainance.c.

◆ delete_from_maintainance_map()

void delete_from_maintainance_map ( object_maintainance obj)

Definition at line 598 of file object_maintainance.c.

◆ delete_object()

void delete_object ( MEMoidKey  key,
MEMoid  oid 
)

The function to delete the object specified.

Parameters
keyThe MEMoidKey of the object that needs to be deleted.
oidThe MEMoid object that represents the object that needs to be deleted.
Returns
Nothing.
Note
This function is responsible for removing the entries about the deleted object from the object_maintainance table and types_table.
See also
on_deletion_timer()

Definition at line 359 of file object_maintainance.c.

Here is the call graph for this function:

◆ deletion_thread_function()

void* deletion_thread_function ( void *  data)

The deletion thread function.

This function starts an uv_loop thats fired after every DELETE_LOOP_SLEEP_TIME amount of time.

Parameters
datathe loop that needs to be started
Note
This function never returns.

Definition at line 135 of file object_maintainance.c.

Here is the call graph for this function:

◆ find_in_maintainance_map()

object_maintainance* find_in_maintainance_map ( MEMoidKey  key)

Definition at line 602 of file object_maintainance.c.

Here is the call graph for this function:

◆ get_hash()

uint64_t get_hash ( object_maintainance entry)

Definition at line 22 of file object_maintainance.c.

◆ HASH_MAP()

HASH_MAP ( object_maintainance  )

Hashmap for object maintaince.

will be used by check_if_required_to_move()

Definition at line 48 of file object_maintainance.c.

◆ initialise_logistics()

void initialise_logistics ( )

Definition at line 79 of file object_maintainance.c.

Here is the call graph for this function:

◆ insert_into_maintainance_map()

void insert_into_maintainance_map ( object_maintainance obj)

Definition at line 594 of file object_maintainance.c.

◆ logistics_thread_function()

void* logistics_thread_function ( void *  data)

The logistics thread function.

This function starts an uv_loop thats fired after every MOVE_LOOP_SLEEP_TIME amount of time.

Parameters
datathe loop that needs to be started
Note
This function never returns.

Definition at line 114 of file object_maintainance.c.

Here is the call graph for this function:

◆ move_to_dram()

void move_to_dram ( uv_work_t *  req)

The function to move an object from NVRAM to DRAM.

Parameters
keythe MEMoidKey of the object that needs to be moved.
oidthe MEMoid object representing the object that needs to be moved.
Returns
Nothing.
Note
This function has to update object_maintainance table and types_table
Attention
This function has to ensure data integrety and pointer validity.
See also
move_to_nvram() on_logistics_timer()

Definition at line 414 of file object_maintainance.c.

Here is the call graph for this function:

◆ move_to_nvram()

void move_to_nvram ( uv_work_t *  req)

The function to move an object from DRAM to NVRAM.

Parameters
keythe MEMoidKey of the object that needs to be moved.
oidthe MEMoid object representing the object that needs to be moved.
Returns
Nothing.
Note
This function has to update object_maintainance table and types_table
Attention
This function has to ensure data integrety and pointer validity.
See also
move_to_dram() on_logistics_timer()

Definition at line 477 of file object_maintainance.c.

Here is the call graph for this function:

◆ on_after_work()

void on_after_work ( uv_work_t *  req,
int  status 
)

Definition at line 531 of file object_maintainance.c.

◆ on_deletion_timer()

void on_deletion_timer ( uv_timer_t *  timer,
int  status 
)

The function thats called when the deletion thread wakes up.

Here all the objects received from memfree() for deletion are deleted.

Definition at line 298 of file object_maintainance.c.

Here is the call graph for this function:

◆ on_logistics_timer()

void on_logistics_timer ( uv_timer_t *  timer,
int  status 
)

The function thats called when the logistic thread wakes up.

Here at first all the new objects created by memalloc() are recorded. Then all the objects are updated using the stats revieved from log_write() and log_read(). And finally the decision for movement of object is made.

Definition at line 182 of file object_maintainance.c.

Here is the call graph for this function:

◆ reset_om()

void reset_om ( object_maintainance om)

Definition at line 163 of file object_maintainance.c.

◆ set_bits()

static size_t set_bits ( uint64_t bitmap,
size_t  offset,
size_t  size 
)
inlinestatic

Definition at line 148 of file object_maintainance.c.

◆ unlock_om()

void unlock_om ( )

Definition at line 75 of file object_maintainance.c.

Variable Documentation

◆ object_maintainence_addtion_mutex

uv_mutex_t object_maintainence_addtion_mutex

The mutex used during manupulation of maintainance map

Definition at line 16 of file object_maintainance.c.

◆ object_maintainence_deletion_mutex

uv_mutex_t object_maintainence_deletion_mutex

The mutex used during manupulation of maintainance map

Definition at line 17 of file object_maintainance.c.

◆ object_maintainence_hashmap_mutex

uv_mutex_t object_maintainence_hashmap_mutex

The mutex used during manupulation of types map

Definition at line 13 of file object_maintainance.c.

◆ object_maintainence_maintain_map_mutex

uv_mutex_t object_maintainence_maintain_map_mutex

The mutex used during manupulation of maintainance map

Definition at line 15 of file object_maintainance.c.

◆ object_maintainence_memory_mutex

uv_mutex_t object_maintainence_memory_mutex

The mutex used during nvm_free / access too.

Definition at line 14 of file object_maintainance.c.

◆ read_splay_tree_mutex

uv_mutex_t read_splay_tree_mutex

The mutex used during manupulation of read splay tree

Definition at line 18 of file object_maintainance.c.

◆ write_splay_tree_mutex

uv_mutex_t write_splay_tree_mutex

The mutex used during manupulation of read splay tree

Definition at line 19 of file object_maintainance.c.