-
Notifications
You must be signed in to change notification settings - Fork 0
/
incll_globals.cc
136 lines (110 loc) · 3.05 KB
/
incll_globals.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Modification of Masstree
* VLSC Laboratory
* Copyright (c) 2018-2019 Ecole Polytechnique Federale de Lausanne
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, subject to the conditions
* listed in the Masstree LICENSE file. These conditions include: you must
* preserve this copyright notice, and you cannot mention the copyright
* holders in advertising related to the Software without their permission.
* The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
* notice is a summary of the Masstree LICENSE file; the license in that file
* is legally binding.
*/
#include "incll_globals.hh"
extern volatile void *global_masstree_root;
#ifdef MTAN
std::atomic<size_t> nflushes(0);
std::atomic<size_t> nupdate_incll(0);
std::atomic<size_t> ninsert_incll(0);
std::atomic<size_t> ninserts(0);
std::atomic<size_t> nrecords_lf(0);
std::atomic<size_t> nrecords_in(0);
void report_mtan(){
printf("Flushes:%lu\n", size_t(nflushes));
printf("Incll update:%lu\n", size_t(nupdate_incll));
printf("Incll insert:%lu\n", size_t(ninsert_incll));
printf("Insert:%lu\n", size_t(ninserts)-GH::n_initops);
printf("Lf records:%lu\n", size_t(nrecords_lf));
printf("In records:%lu\n", size_t(nrecords_in));
}
#endif //MTAN
namespace GH{
ThreadBarrier thread_barrier;
#ifdef INCLL
BucketLocks bucket_locks;
#endif
std::string exp_name;
uint64_t n_keys = 50;
uint64_t n_initops = 25;
uint64_t n_ops1 = 20;
uint64_t n_ops2 = 5;
int get_rate = 50;
int put_rate = 25;
int rem_rate = 25;
int scan_rate = 0;
void check_rate(int rate){
assert(rate <= 100);
}
#ifdef GLOBAL_FLUSH
GlobalFlush global_flush;
#endif
#ifdef EXTLOG
thread_local PExtNodeLogger *node_logger;
PLogAllocator plog_allocator;
#endif //extlog
void print_exp_params(){
printf("nkeys:%lu ninitops:%lu "
"nops1:%lu nops2:%lu "
"get rate:%d put rate:%d rem rate:%d scan rate:%d\n",
n_keys, n_initops,
n_ops1, n_ops2,
get_rate, put_rate, rem_rate, scan_rate);
}
void set_exp_name(const char *exp){
exp_name = std::string(exp);
#ifdef GLOBAL_FLUSH
exp_name += "_gl" + std::to_string(GL_FREQ);
#endif
}
void init_all(int nthreads, const char *testname){
srand(0);
thread_barrier.init(nthreads);
set_exp_name(testname);
#ifdef GLOBAL_FLUSH
global_flush.init(nthreads);
#endif //gf
#ifdef INCLL
bucket_locks.init();
#endif //incll
#ifdef EXTLOG
plog_allocator.init();
#endif //extlog
}
void init_thread_all(int tid){
#ifdef EXTLOG
node_logger = plog_allocator.init_plog(tid);
#endif //extlog
}
#ifdef EXTLOG
bool is_recovery(){
return plog_allocator.exists;
}
#endif //extlog
void advance_epoch(int tid, void *root){
#ifdef GLOBAL_FLUSH
thread_barrier.wait_barrier(tid);
if(tid == 0){
global_masstree_root = root;
global_flush.flush_manual();
}else{
global_flush.ack_flush_manual();
}
#ifdef EXTLOG
node_logger->checkpoint();
#endif
thread_barrier.wait_barrier(tid);
#endif
}
};