NVMLib  very early alpha
A library to optimally use a Hybrid RAM setup.
object_maintainance.c
Go to the documentation of this file.
1 #include "object_maintainance.h"
2 #include "types.h"
3 #include "malloc.h"
4 #include <libpmemobj.h>
5 #include "globals.h"
6 #include "pool.h"
7 #include "hashmap.h"
8 #include "mem_log.h"
9 #include "log.h"
10 #include <uv.h>
11 #include <pthread.h>
12 
13 uv_mutex_t object_maintainence_hashmap_mutex; // used during manupulation of `types map`
14 uv_mutex_t object_maintainence_memory_mutex; // used during `nvm_free` / access too
15 uv_mutex_t object_maintainence_maintain_map_mutex; // used during manupulation of `maintainance map`
16 uv_mutex_t object_maintainence_addtion_mutex; // used during manupulation of `addition_queue`
17 uv_mutex_t object_maintainence_deletion_mutex; // used during manupulation of `deletion_queue`
18 uv_mutex_t read_splay_tree_mutex; // used during manupulation of `read splay tree`
19 uv_mutex_t write_splay_tree_mutex; // used during manupulation of `read splay tree`
20 
21 
23  return entry->key;
24 }
25 
27  if(a->key == b->key) {
28  return 0;
29  }
30  return 1;
31 }
32 
33 #ifdef DEBUG
34 void print(object_maintainance *entry) {
35  printf("%ld -- num_read %ld , num_writes %ld", entry->key, entry->num_reads, entry->num_writes);
36 }
37 #endif
38 
47 
48 HASH_MAP(object_maintainance) *object_maintainance_map;
49 
50 #ifdef DEBUG
52 #endif
53 
57 void on_logistics_timer(uv_timer_t *timer, int status);
58 void on_deletion_timer(uv_timer_t *timer, int status);
59 void *logistics_thread_function(void *data);
60 void *deletion_thread_function(void *data);
61 void move_to_nvram(uv_work_t *req);
62 void move_to_dram(uv_work_t *req);
63 void on_after_work(uv_work_t* req, int status);
64 // void delete_object(uv_work_t *req);
65 void delete_object(MEMoidKey key, MEMoid oid);
70 
71 void lock_om(){
72  uv_mutex_lock(&object_maintainence_hashmap_mutex);
73 }
74 
75 void unlock_om() {
76  uv_mutex_unlock(&object_maintainence_hashmap_mutex);
77 }
78 
80 
81  // Initialising hashmap for logistics
83 
85 
86  // Initialising the mutexes
87  uv_mutex_init(&object_maintainence_hashmap_mutex);
88  uv_mutex_init(&object_maintainence_memory_mutex);
90  uv_mutex_init(&object_maintainence_addtion_mutex);
91 
92  uv_mutex_init(&read_splay_tree_mutex);
93  uv_mutex_init(&write_splay_tree_mutex);
94 
95 
96  // The logistics and deletion threads
97  pthread_t logistics_thread, deletion_thread;
98 
99  uv_loop_t *logistics_loop = uv_loop_new();
100  pthread_create(&logistics_thread, NULL, logistics_thread_function, logistics_loop);
101 
102  uv_loop_t *deletion_loop = uv_loop_new();
103  pthread_create(&deletion_thread, NULL, deletion_thread_function, deletion_loop);
104 }
105 
114 void *logistics_thread_function(void *data){
115  uv_loop_t *thread_loop = (uv_loop_t *) data;
116  LOG_INFO("Logistics thread will start event loop\n");
117 
118  uv_timer_t timer_logistics;
119  uv_timer_init(thread_loop, &timer_logistics);
120  uv_timer_start(&timer_logistics, (uv_timer_cb)on_logistics_timer, 0, MOVE_LOOP_SLEEP_TIME);
121 
122  //Start this loop
123  uv_run(thread_loop, UV_RUN_DEFAULT);
124  pthread_exit(NULL);
125 }
126 
135 void *deletion_thread_function(void *data){
136  uv_loop_t *thread_loop = (uv_loop_t *) data;
137  LOG_INFO("Deletion thread will start event loop\n");
138 
139  uv_timer_t timer_logistics;
140  uv_timer_init(thread_loop, &timer_logistics);
141  uv_timer_start(&timer_logistics, (uv_timer_cb)on_deletion_timer, 0, MOVE_LOOP_SLEEP_TIME);
142 
143  //Start this loop
144  uv_run(thread_loop, UV_RUN_DEFAULT);
145  pthread_exit(NULL);
146 }
147 
148 static inline size_t set_bits(uint64_t* bitmap, size_t offset, size_t size) {
149  int byteno = offset/64;
150  int shift = offset%64;
151  size_t new_set = 0;
152  uint64_t bit = 1<<shift;
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;
157  shift++;
158  bit <<= 1;
159  }
160  return new_set;
161 }
162 
164  om->num_reads = 0;
165  om->num_writes = 0;
166  om->last_read = NULL;
167  om->last_write = NULL;
168  om->last_read_size = 0;
169  om->last_write_size = 0;
170  om->bytes_read = 0;
171  om->bytes_write =0;
172 }
173 
174 
182 void on_logistics_timer(uv_timer_t *timer, int status) {
183  uv_work_t* work_req;
185 
186  if(!object_maintainance_map->entries){
187  // nothing yet in the logistics map
188  return;
189  }
190 
191  uv_mutex_lock(&object_maintainence_addtion_mutex);
192  while(!TAILQ_EMPTY(&addition_queue_head)) {
193  object_maintainance_deletion *to_add = TAILQ_FIRST(&addition_queue_head);
194 
197  uv_mutex_unlock(&object_maintainence_maintain_map_mutex);
198 
199  TAILQ_REMOVE(&addition_queue_head, to_add, list);
200  }
201  uv_mutex_unlock(&object_maintainence_addtion_mutex);
202 
203  while(!TAILQ_EMPTY(&write_queue_head)) {
204  address_log* w_add = TAILQ_FIRST(&write_queue_head);
205  // addr2memoid_key skey;
206  // skey.comp = cmp_addr;
207  // skey.addr = w_add->addr;
208 
209  // uv_mutex_lock(&write_splay_tree_mutex);
210  // splay_tree_node ret_node = splay_tree_lookup(addr2MemOID_write, (splay_tree_key)&skey);
211 
212  // MEMoidKey mkey = ((addr2memoid_key*)ret_node->key)->key;
213  // uv_mutex_unlock(&write_splay_tree_mutex);
214  MEMoidKey mkey = w_add->key;
216  om->num_writes++;
217  om->last_accessed_at = w_add->access_time;
218  size_t ent_inc = set_bits(om->write_bitmap, w_add->offset, w_add->size);
219  if (om->last_write + om->last_write_size != w_add->offset && w_add->offset + w_add->size != om->last_write) {
220  om->w_entropy += ent_inc;
221  }
222  om->last_write = w_add->offset;
223  om->last_write_size = w_add->size;
224  om->bytes_write += w_add->size;
225  TAILQ_REMOVE(&write_queue_head, w_add, list);
226  }
227  while(!TAILQ_EMPTY(&read_queue_head)) {
228  address_log* r_add = TAILQ_FIRST(&read_queue_head);
229  // addr2memoid_key skey;
230  // skey.comp = cmp_addr;
231  // skey.addr = r_add->addr;
232 
233  // uv_mutex_lock(&read_splay_tree_mutex);
234  // splay_tree_node ret_node = splay_tree_lookup(addr2MemOID_read, (splay_tree_key)&skey);
235 
236  // MEMoidKey mkey = ((addr2memoid_key*)ret_node->key)->key;
237  // uv_mutex_unlock(&read_splay_tree_mutex);
238  MEMoidKey mkey = r_add->key;
240  om->num_reads++;
241  om->last_accessed_at = r_add->access_time;
242  size_t ent_inc = set_bits(om->read_bitmap, r_add->offset, r_add->size);
243  if (om->last_read + om->last_read_size != r_add->offset && r_add->offset + r_add->size != om->last_read ) {
244  om->r_entropy += ent_inc;
245  }
246  om->last_read = r_add->offset;
247  om->last_read_size = r_add->size;
248  om->bytes_read += r_add->size;
249  TAILQ_REMOVE(&read_queue_head, r_add, list);
250  }
251 
252 #ifdef DEBUG
253  // debug
254  HASH_MAP_PRINT(object_maintainance)(object_maintainance_map);
255 #endif
256 
257  for(size_t i=0; i<object_maintainance_map->power_of_two; i++) {
258  HASH_MAP_BUCKET(object_maintainance) *bucket = &object_maintainance_map->entries[i];
259  for(int j = 0; j < bucket->size; j++) {
260  // by value !!!
261  var = bucket->entries[j];
262  //var.r_entropy = var.bytes_read / var.r_entropy;
263  //var.w_entropy = var.bytes_write / var.w_entropy;
264  int ret = check_if_required_to_move(var);
265  switch (ret){
266  case 1:
267  work_req = (uv_work_t*)malloc(sizeof(*work_req));
268  work_req->data = malloc(sizeof(object_maintainance));
269  *((object_maintainance *)(work_req->data)) = var;
270 
271  //uv_queue_work(timer->loop, work_req, move_to_nvram, on_after_work);
272  move_to_nvram(work_req);
273  on_after_work(work_req, 0);
274  break;
275  case 2:
276  work_req = (uv_work_t*)malloc(sizeof(*work_req));
277  work_req->data = malloc(sizeof(object_maintainance));
278  *((object_maintainance *)(work_req->data)) = var;
279 
280  //uv_queue_work(timer->loop, work_req, move_to_dram, on_after_work);
281  move_to_dram(work_req);
282  on_after_work(work_req, 0);
283  break;
284  default:
285  break;
286  }
287  reset_om(&var);
288  }
289  }
290 }
291 
292 
298 void on_deletion_timer(uv_timer_t *timer, int status) {
299  uv_work_t* work_req;
301  if(!object_maintainance_map->entries){
302  // nothing yet in the logistics map
303  return;
304  }
305 
306  uv_mutex_lock(&object_maintainence_deletion_mutex);
307 
308  while(!TAILQ_EMPTY(&deletion_queue_head)) {
309  object_maintainance_addition *to_delete = TAILQ_FIRST(&deletion_queue_head);
310 
311  delete_object(to_delete->key, to_delete->oid);
312 
313  TAILQ_REMOVE(&deletion_queue_head, to_delete, list);
314  }
315  uv_mutex_unlock(&object_maintainence_deletion_mutex);
316 
317 
318  // for(size_t i=0; i<object_maintainance_map->power_of_two; i++) {
319  // HASH_MAP_BUCKET(object_maintainance) *bucket = &object_maintainance_map->entries[i];
320  // for(int j = 0; j < bucket->size; j++) {
321  // // by value !!!
322  // var = bucket->entries[j];
323 
324  // int ret = check_if_required_to_delete(var);
325  // if(ret) {
326  // // Needs to be deleted
327  // work_req = (uv_work_t*)malloc(sizeof(*work_req));
328  // work_req->data = malloc(sizeof(object_maintainance));
329  // *((object_maintainance *)(work_req->data)) = var;
330 
331  // //uv_queue_work(timer->loop, work_req, delete_object, on_after_work);
332  // delete_object(work_req);
333  // on_after_work(work_req, 0);
334  // LOG_INFO("delete_object scheduled: %ld from %d at [%ld ms]\n", var.key, var.which_ram, (uv_hrtime() / 1000000) % 100000);
335  // }
336  // }
337  // }
338 }
339 
340 // void delete_object(uv_work_t *req){
341 // MEMoidKey key = ((object_maintainance*)(req->data))->key;
342 // MEMoid oid = ((object_maintainance*)(req->data))->oid;
343 // size_t size = oid.size;
344 // bool is_dram = false;
345 
346 
360 
361  size_t size = oid.size;
362  bool is_dram = false;
363 
364  // Get the hashmap mutex first to ensure there are no leftover accesses
365  uv_mutex_lock(&object_maintainence_hashmap_mutex);
366 
367  switch (oid.pool_id) {
368  case POOL_ID_MALLOC_OBJ:
369  // dram object
370 
371  // freeing the contents in dram
372  uv_mutex_lock(&object_maintainence_memory_mutex);
373  free((void*)oid.offset);
374  uv_mutex_unlock(&object_maintainence_memory_mutex);
375  is_dram = true;
376  break;
377 
378  default:
379  // nvram object
380 
381  // freeing the contents in nvram
382  uv_mutex_lock(&object_maintainence_memory_mutex);
383  nvm_free(oid.pool_id, oid.offset, size);
384  uv_mutex_unlock(&object_maintainence_memory_mutex);
385  break;
386  }
387 
388  // deleting the object from `types map`
390 
391  uv_mutex_unlock(&object_maintainence_hashmap_mutex);
392 
393  // Updating the `object_maintainance_map`
396  uv_mutex_unlock(&object_maintainence_maintain_map_mutex);
397 
398  LOG_INFO("delete_object: %ld from %s at [%ld ms]\n", key, is_dram?"DRAM":"NVRAM", (uv_hrtime() / 1000000) % 100000);
399 }
400 
401 
414 void move_to_dram(uv_work_t *req) {
415  MEMoidKey key = ((object_maintainance*)(req->data))->key;
416  MEMoid oid = ((object_maintainance*)(req->data))->oid;
417  size_t size = oid.size;
418 
419  MEMoid new_obj;
420  new_obj.offset = (uint64_t)(malloc(size));
421  new_obj.pool_id = POOL_ID_MALLOC_OBJ;
422  new_obj.size = size;
423 #ifdef DEBUG
424  printf("move to dram dram poolid = %d, offset = %d addr = %p\n", new_obj.pool_id, new_obj.offset, (void*)get_pool_from_poolid(new_obj.pool_id)+new_obj.offset);
425 #endif
426  // copying the object contents
427  memcpy((void*)new_obj.offset, (void*)(get_pool_from_poolid(oid.pool_id) + oid.offset), size);
428 
429  // Get the hashmap mutex first to ensure there are no leftover accesses
430  uv_mutex_lock(&object_maintainence_hashmap_mutex);
431  // updating the `types_table`
432  // NOTE: we have to mannually delete before inserting for the same key
434  insert_object_to_hashmap(key, new_obj);
435 
436  // freeing the contents in nvram
437  uv_mutex_lock(&object_maintainence_memory_mutex);
438  nvm_free(oid.pool_id, oid.offset, size);
439  uv_mutex_unlock(&object_maintainence_memory_mutex);
440 
441  //debug_hashmap(key);
442  uv_mutex_unlock(&object_maintainence_hashmap_mutex);
443 
444  // Updating the `object_maintainance_map`
446 
447  object_maintainance *new_maintainance_map_obj = (object_maintainance *)malloc(sizeof(object_maintainance));
448  // by value !!!
449  *new_maintainance_map_obj = *((object_maintainance*)(req->data));
450  // changed fields
451  new_maintainance_map_obj->oid = new_obj;
452  new_maintainance_map_obj->shift_level = JUST_ENTERED;
453  new_maintainance_map_obj->which_ram = DRAM;
454 
455  // not this replaces the previous
456  insert_into_maintainance_map(new_maintainance_map_obj);
457 
458  uv_mutex_unlock(&object_maintainence_maintain_map_mutex);
459 
460  LOG_INFO("move_to_dram: %ld at [%ld ms]\n", key, (uv_hrtime() / 1000000) % 100000);
461 }
462 
463 
464 
477 void move_to_nvram(uv_work_t *req) {
478 
479  MEMoidKey key = ((object_maintainance*)(req->data))->key;
480  MEMoid oid = ((object_maintainance*)(req->data))->oid;
481  size_t size = oid.size;
482 
483  MEMoid new_obj;
484  // new_obj.pool_id = get_current_poolid();
485  // new_obj.offset = get_first_free_offset(size);
486  // new_obj.size = size;
487  new_obj = allot_first_free_offset(size);
488 #ifdef DEBUG
489  printf("move to nvram nvram poolid = %d, offset = %d addr = %p\n", new_obj.pool_id, new_obj.offset, (void*)get_pool_from_poolid(new_obj.pool_id)+new_obj.offset);
490 #endif
491  memcpy((void*)(get_pool_from_poolid(new_obj.pool_id) + new_obj.offset), (void*)oid.offset, size);
492  //TODO: need to call peme_persist ... later!!
493 
494  // Get the hashmap mutex first to ensure there are no leftover accesses
495  uv_mutex_lock(&object_maintainence_hashmap_mutex);
496 
497  // updating the `types_table`
498  // NOTE: we have to mannually delete before inserting for the same key
500  insert_object_to_hashmap(key, new_obj);
501 
502  // freeing the contents in dram
503  uv_mutex_lock(&object_maintainence_memory_mutex);
504  free((void*)oid.offset);
505  uv_mutex_unlock(&object_maintainence_memory_mutex);
506 
507  //debug_hashmap(key);
508  uv_mutex_unlock(&object_maintainence_hashmap_mutex);
509 
510 
511  // Updating the `object_maintainance_map`
513 
514  object_maintainance *new_maintainance_map_obj = (object_maintainance *)malloc(sizeof(object_maintainance));
515  // by value !!!
516  *new_maintainance_map_obj = *((object_maintainance*)(req->data));
517  // changed fields
518  new_maintainance_map_obj->oid = new_obj;
519  new_maintainance_map_obj->shift_level = JUST_ENTERED;
520  new_maintainance_map_obj->which_ram = NVRAM;
521 
522  // not this replaces the previous
523  insert_into_maintainance_map(new_maintainance_map_obj);
524 
525  uv_mutex_unlock(&object_maintainence_maintain_map_mutex);
526 
527  LOG_INFO("move_to_nvram: %ld at [%ld ms]\n", key, (uv_hrtime() / 1000000) % 100000);
528 }
529 
530 
531 void on_after_work(uv_work_t* req, int status) {
532  free(req);
533 }
534 
535 
536 
537 
538 // Checks if an object can be deleted or not
539 // @return : 1 - If can be deleted
540 // 0 - otherwise
542 
543  return entry.which_ram == NO_RAM ? 1 : 0;
544 }
545 
555  // To be completed
556  if (!entry.can_be_moved) {
557  return 0;
558  }
559  int ret = 0;
560  if (entry.which_ram == NO_RAM || entry.which_ram == RAM_UNKNOWN) return 0;
561  return entry.which_ram==DRAM?1:2;
562  // return 0;
563 }
564 
565 
567  object_maintainance_map = HASH_MAP_CREATE(object_maintainance)();
568 }
569 
571  object_maintainance* obj = (object_maintainance *)malloc(sizeof(object_maintainance) * 1);
572  obj->key = key;
573  obj->oid = oid;
574  obj->num_reads = 0;
575  obj->num_writes = 0;
576  obj->last_accessed_at = time(NULL);
579  obj->write_bitmap = (uint64_t*)malloc(sizeof(uint64_t)*(ceil((double)oid.size/64)));
580  obj->read_bitmap = (uint64_t*)malloc(sizeof(uint64_t)*(ceil((double)oid.size/64)));
581  obj->which_ram = which_ram;
582  obj->shift_level = JUST_ENTERED;
583  obj->can_be_moved = can_be_moved;
584  obj->last_read = NULL;
585  obj->last_write = NULL;
586  obj->last_read_size = 0;
587  obj->last_write_size = 0;
588  obj->bytes_read = 0;
589  obj->bytes_write =0;
590 
591  return obj;
592 }
593 
595  HASH_MAP_INSERT(object_maintainance)(object_maintainance_map, &obj, HMDR_REPLACE);
596 }
597 
599  HASH_MAP_ERASE(object_maintainance)(object_maintainance_map, obj);
600 }
601 
603  // A placeholder for the actual object in the map
605 
606  bool is_found = HASH_MAP_FIND(object_maintainance)(object_maintainance_map, &found_obj);
607 
608  if(is_found) {
609  return found_obj;
610  }
611  return NULL;
612 
613 }
614 
615 
617  TAILQ_INIT(&addition_queue_head);
618  TAILQ_INIT(&deletion_queue_head);
619 }
620 
621 
622 // ==============================================================================================================================
623 // D E P R I C A T E D C O D E
624 // ==============================================================================================================================
625 
626 // uv_loop_t* get_logistics_loop() {
627 // return uv_is_active(deletion_loop) ? deletion_loop : NULL;
628 // }
629 
630 
631 // // never return unless faults
632 // void delete_objects() {
633 // TOID(struct hashmap_tx) *hashmap = get_types_map();
634 
635 // TOID(struct buckets) buckets = D_RO(hashmap)->buckets;
636 // TOID(struct entry) var;
637 
638 // while(1){
639 // for (size_t i = 0; i < D_RO(buckets)->nbuckets; ++i) {
640 // if (TOID_IS_NULL(D_RO(buckets)->bucket[i]))
641 // continue;
642 
643 // for (var = D_RO(buckets)->bucket[i]; !TOID_IS_NULL(var);
644 // var = D_RO(var)->next) {
645 // ret = check_if_required_to_delete(D_RO(var)->key, D_RO(var)->value);
646 // if(ret) {
647 // // Needs to be deleted
648 // memfree(D_RO(var)->value);
649 // }
650 // }
651 // }
652 
653 // // resume operation every 5 min
654 // sleep(DELETE_LOOP_SLEEP_TIME);
655 // }
656 // }
657 
658 // // never return unless faults
659 // void move_objects() {
660 // TOID(struct hashmap_tx) *hashmap = get_types_map();
661 
662 // TOID(struct buckets) buckets = D_RO(hashmap)->buckets;
663 // TOID(struct entry) var;
664 
665 // while(1){
666 // for (size_t i = 0; i < D_RO(buckets)->nbuckets; ++i) {
667 // if (TOID_IS_NULL(D_RO(buckets)->bucket[i]))
668 // continue;
669 
670 // for (var = D_RO(buckets)->bucket[i]; !TOID_IS_NULL(var);
671 // var = D_RO(var)->next) {
672 // ret = check_if_required_to_move(D_RO(var)->key, D_RO(var)->value);
673 // switch (ret){
674 // case 1:
675 // move_to_nvram(D_RO(var)->key, D_RO(var)->value, sizeof(TOID_TYPEOF(var)));
676 // break;
677 // case 2:
678 // move_to_dram(D_RO(var)->key, D_RO(var)->value, sizeof(TOID_TYPEOF(var)));
679 // break;
680 // default:
681 // break;
682 // }
683 // }
684 // }
685 
686 // // resume operation every 5 min
687 // sleep(MOVE_LOOP_SLEEP_TIME);
688 // }
689 // }
690 
691 
692 // void move_to_dram(MEMoidKey key, MEMoid oid, size_t size) {
693 // MEMoid new_obj;
694 // new_obj.offset = (uint64_t)(malloc(size));
695 // new_obj.pool_id = POOL_ID_MALLOC_OBJ;
696 
697 // // copying the object contents
698 // memcpy(new_obj.offset, get_pool_from_poolid(oid.pool_id) + oid.offset, size);
699 
700 // // freeing the contents in nvram
701 // nvm_free(oid.pool_id, oid.offset, size);
702 
703 // // updating the `types_table`
704 // // NOTE: we have to mannually delete before inserting for the same key
705 // remove_object_from_hashmap(key);
706 // insert_object_to_hashmap(key, new_obj);
707 
708 // // need to update the levels list
709 // }
710 
711 // void move_to_nvram(MEMoidKey key, MEMoid oid, size_t size) {
712 // MEMoid new_obj;
713 // new_obj.pool_id = get_current_poolid();
714 // new_obj.offset = get_first_free_offset(size);
715 
716 // memcpy(get_pool_from_poolid(new_obj.pool_id) + new_obj.offset, oid.offset, size);
717 // //TODO: need to call peme_persist ... later!!
718 
719 // // updating the `types_table`
720 // // NOTE: we have to mannually delete before inserting for the same key
721 // remove_object_from_hashmap(key);
722 // insert_object_to_hashmap(key, new_obj);
723 
724 // // need to update the levels list
725 // }
address_log::access_time
time_t access_time
Definition: mem_log.h:12
write_splay_tree_mutex
uv_mutex_t write_splay_tree_mutex
The mutex used during manupulation of read splay tree
Definition: object_maintainance.c:19
HASH_MAP
HASH_MAP(object_maintainance)
Hashmap for object maintaince.
Definition: object_maintainance.c:48
logistics_thread_function
void * logistics_thread_function(void *data)
The logistics thread function.
Definition: object_maintainance.c:114
initialise_logistics
void initialise_logistics()
Definition: object_maintainance.c:79
object_maintainence_maintain_map_mutex
uv_mutex_t object_maintainence_maintain_map_mutex
The mutex used during manupulation of maintainance map
Definition: object_maintainance.c:15
MEMoid_st::offset
uint64_t offset
Definition: malloc.h:31
address_log
Definition: mem_log.h:8
object_maintainance_st::r_entropy
uint64_t r_entropy
Definition: object_maintainance.h:53
object_maintainance_st::last_write_size
size_t last_write_size
Definition: object_maintainance.h:56
object_maintainance_st::last_write
void * last_write
Definition: object_maintainance.h:54
compare
int compare(object_maintainance *a, object_maintainance *b)
Definition: object_maintainance.c:26
types.h
get_pool_from_poolid
uintptr_t get_pool_from_poolid(uint64_t pool_id)
Definition: pool.c:79
insert_object_to_hashmap
void insert_object_to_hashmap(MEMoidKey key, MEMoid oid)
Definition: types.c:70
object_maintainance_st::can_be_moved
bool can_be_moved
Definition: object_maintainance.h:65
lock_om
void lock_om()
delete_object
void delete_object(MEMoidKey key, MEMoid oid)
The function to delete the object specified.
Definition: object_maintainance.c:359
object_maintainance_st::oid
MEMoid oid
Definition: object_maintainance.h:41
NO_RAM
@ NO_RAM
Definition: object_maintainance.h:34
unlock_om
void unlock_om()
Definition: object_maintainance.c:75
address_log::key
MEMoidKey key
Definition: mem_log.h:9
DECLARE_HASHMAP
DECLARE_HASHMAP(pool_free_slot_val)
check_if_required_to_move
int check_if_required_to_move(object_maintainance entry)
Checks if an object can be moved or not.
Definition: object_maintainance.c:554
LOG_INFO
#define LOG_INFO(message, args...)
Definition: log.h:54
MEMoid_st
The struct that stores the memptr for the object.
Definition: malloc.h:29
object_maintainance_st::shift_level
shift_levels_t shift_level
Definition: object_maintainance.h:63
HASH_MAP_BUCKET
#define HASH_MAP_BUCKET(VALUE_TYPE)
Definition: hashmap.h:30
object_maintainance_st::num_writes
uint32_t num_writes
Definition: object_maintainance.h:44
object_maintainance_st::read_bitmap
uint64_t * read_bitmap
Definition: object_maintainance.h:50
MEMoidKey
uint64_t MEMoidKey
The key of the HashTable that contains <MEMoidKey, MEMoid>.
Definition: malloc.h:49
object_maintainance_st::which_ram
where_t which_ram
Definition: object_maintainance.h:61
MEMoid_st::size
size_t size
Definition: malloc.h:32
read_splay_tree_mutex
uv_mutex_t read_splay_tree_mutex
The mutex used during manupulation of read splay tree
Definition: object_maintainance.c:18
move_to_dram
void move_to_dram(uv_work_t *req)
The function to move an object from NVRAM to DRAM.
Definition: object_maintainance.c:414
hashmap.h
allot_first_free_offset
MEMoid allot_first_free_offset(size_t size)
Allocates the first free memory chunk of the given size.
Definition: malloc.c:104
deletion_thread_function
void * deletion_thread_function(void *data)
The deletion thread function.
Definition: object_maintainance.c:135
DRAM
@ DRAM
Definition: object_maintainance.h:32
object_maintainance_addition
Definition: object_maintainance.h:69
object_maintainance_st::num_reads
uint32_t num_reads
Definition: object_maintainance.h:43
on_logistics_timer
void on_logistics_timer(uv_timer_t *timer, int status)
The function thats called when the logistic thread wakes up.
Definition: object_maintainance.c:182
NVRAM
@ NVRAM
Definition: object_maintainance.h:33
object_maintainance_st::key
MEMoidKey key
Definition: object_maintainance.h:40
globals.h
HMDR_REPLACE
@ HMDR_REPLACE
Definition: hashmap.h:41
object_maintainance_deletion::oid
MEMoid oid
Definition: object_maintainance.h:82
where_t
enum where_en where_t
object_maintainance.h
pool.h
entry::key
uint64_t key
Definition: hashmap_tx.h:34
object_maintainance_st::w_entropy
uint64_t w_entropy
Definition: object_maintainance.h:52
remove_object_from_hashmap
void remove_object_from_hashmap(MEMoidKey key)
Definition: types.c:74
uint64_t
__uint64_t uint64_t
Definition: globals.h:51
HASH_MAP_ERASE
#define HASH_MAP_ERASE(VALUE_TYPE)
Definition: hashmap.h:35
object_maintainance_st::bytes_write
size_t bytes_write
Definition: object_maintainance.h:58
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: object_maintainance.c:570
object_maintainance_deletion::key
MEMoidKey key
Definition: object_maintainance.h:81
delete_from_maintainance_map
void delete_from_maintainance_map(object_maintainance *obj)
Definition: object_maintainance.c:598
mem_log.h
MOVE_LOOP_SLEEP_TIME
#define MOVE_LOOP_SLEEP_TIME
Definition: uv_loop_demo_example.c:23
find_in_maintainance_map
object_maintainance * find_in_maintainance_map(MEMoidKey key)
Definition: object_maintainance.c:602
malloc.h
HASH_MAP_INSERT
#define HASH_MAP_INSERT(VALUE_TYPE)
Definition: hashmap.h:32
object_maintainance_deletion::which_ram
where_t which_ram
Definition: object_maintainance.h:84
check_if_required_to_delete
int check_if_required_to_delete(object_maintainance entry)
Definition: object_maintainance.c:541
insert_into_maintainance_map
void insert_into_maintainance_map(object_maintainance *obj)
Definition: object_maintainance.c:594
object_maintainance_deletion
Definition: object_maintainance.h:80
object_maintainence_addtion_mutex
uv_mutex_t object_maintainence_addtion_mutex
The mutex used during manupulation of maintainance map
Definition: object_maintainance.c:16
on_deletion_timer
void on_deletion_timer(uv_timer_t *timer, int status)
The function thats called when the deletion thread wakes up.
Definition: object_maintainance.c:298
HASH_MAP_PRINT_FUNC
#define HASH_MAP_PRINT_FUNC(VALUE_TYPE, PRINT_OBJ_FUNC)
Definition: hashmap.h:295
object_maintainance_st::last_accessed_at
time_t last_accessed_at
Definition: object_maintainance.h:45
log.h
NULL
#define NULL
Definition: list.h:13
object_maintainance_st
The structure used by the logistics thread for keeping track of the object state in order to make dif...
Definition: object_maintainance.h:39
create_addition_deletion_queues
void create_addition_deletion_queues()
Definition: object_maintainance.c:616
object_maintainence_deletion_mutex
uv_mutex_t object_maintainence_deletion_mutex
The mutex used during manupulation of maintainance map
Definition: object_maintainance.c:17
on_after_work
void on_after_work(uv_work_t *req, int status)
Definition: object_maintainance.c:531
object_maintainence_memory_mutex
uv_mutex_t object_maintainence_memory_mutex
The mutex used during nvm_free / access too.
Definition: object_maintainance.c:14
object_maintainance_deletion::can_be_moved
bool can_be_moved
Definition: object_maintainance.h:85
set_bits
static size_t set_bits(uint64_t *bitmap, size_t offset, size_t size)
Definition: object_maintainance.c:148
MEMoid_st::pool_id
uint64_t pool_id
Definition: malloc.h:30
entry
Definition: hashmap_tx.h:33
object_maintainance_addition::key
MEMoidKey key
Definition: object_maintainance.h:70
object_maintainance_st::last_read_size
size_t last_read_size
Definition: object_maintainance.h:57
ACCESS_UNKNOWN
@ ACCESS_UNKNOWN
Definition: object_maintainance.h:16
object_maintainance_st::time_since_previous_access
time_t time_since_previous_access
Definition: object_maintainance.h:46
address_log::size
size_t size
Definition: mem_log.h:11
object_maintainence_hashmap_mutex
uv_mutex_t object_maintainence_hashmap_mutex
The mutex used during manupulation of types map
Definition: object_maintainance.c:13
object_maintainance_st::bytes_read
size_t bytes_read
Definition: object_maintainance.h:59
HASH_MAP_PRINT
#define HASH_MAP_PRINT(VALUE_TYPE)
For Debug purposes.
Definition: hashmap.h:293
HASH_MAP_CREATE
#define HASH_MAP_CREATE(VALUE_TYPE)
Definition: hashmap.h:34
JUST_ENTERED
@ JUST_ENTERED
Definition: object_maintainance.h:22
DEFINE_HASHMAP
#define DEFINE_HASHMAP(VALUE_TYPE, CMP, GET_HASH, FREE, REALLOC)
Definition of the declared HashMap.
Definition: hashmap.h:126
object_maintainance_addition::oid
MEMoid oid
Definition: object_maintainance.h:71
object_maintainance_st::write_bitmap
uint64_t * write_bitmap
Definition: object_maintainance.h:49
POOL_ID_MALLOC_OBJ
#define POOL_ID_MALLOC_OBJ
Definition: pool.h:9
move_to_nvram
void move_to_nvram(uv_work_t *req)
The function to move an object from DRAM to NVRAM.
Definition: object_maintainance.c:477
RAM_UNKNOWN
@ RAM_UNKNOWN
Definition: object_maintainance.h:31
HASH_MAP_FIND
#define HASH_MAP_FIND(VALUE_TYPE)
Definition: hashmap.h:33
get_MEMoid
MEMoid get_MEMoid(MEMoidKey key)
The function to obtain the MEMoid object given the MEMoidKey
Definition: types.c:64
nvm_free
void nvm_free(uint64_t pool_id, uint64_t offset, size_t size)
Definition: pool.c:137
reset_om
void reset_om(object_maintainance *om)
Definition: object_maintainance.c:163
get_hash
uint64_t get_hash(object_maintainance *entry)
Definition: object_maintainance.c:22
create_maintainance_map
void create_maintainance_map()
Definition: object_maintainance.c:566
object_maintainance_st::previous_access_type
access_types_t previous_access_type
Definition: object_maintainance.h:47
address_log::offset
size_t offset
Definition: mem_log.h:10
object_maintainance_st::last_read
void * last_read
Definition: object_maintainance.h:55