-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathworkload.cpp
executable file
·808 lines (661 loc) · 21.8 KB
/
workload.cpp
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
#include "./pcm/pcm-memory.cpp"
#include "./pcm/pcm-numa.cpp"
#include "./papi_util.cpp"
#include "microbench.h"
#include <cstring>
#include <cctype>
#include <atomic>
thread_local long skiplist_steps = 0;
std::atomic<long> skiplist_total_steps;
//#define USE_TBB
#ifdef USE_TBB
#include "tbb/tbb.h"
#endif
// Enable this if you need pre-allocation utilization
//#define BWTREE_CONSOLIDATE_AFTER_INSERT
#ifdef BWTREE_CONSOLIDATE_AFTER_INSERT
#ifdef USE_TBB
#warning "Could not use TBB and BwTree consolidate together"
#endif
#endif
#ifdef BWTREE_COLLECT_STATISTICS
#ifdef USE_TBB
#warning "Could not use TBB and BwTree statistics together"
#endif
#endif
// Whether insert interleaves
//#define INTERLEAVED_INSERT
// Whether read operatoin miss will be counted
//#define COUNT_READ_MISS
typedef uint64_t keytype;
typedef std::less<uint64_t> keycomp;
static const uint64_t key_type=0;
static const uint64_t value_type=1; // 0 = random pointers, 1 = pointers to keys
extern bool hyperthreading;
// This is the flag for whather to measure memory bandwidth
static bool memory_bandwidth = false;
// Whether to measure NUMA Throughput
static bool numa = false;
// Whether we only perform insert
static bool insert_only = false;
// We could set an upper bound of the number of loaded keys
static int64_t max_init_key = -1;
#include "util.h"
/*
* MemUsage() - Reads memory usage from /proc file system
*/
size_t MemUsage() {
FILE *fp = fopen("/proc/self/statm", "r");
if(fp == nullptr) {
fprintf(stderr, "Could not open /proc/self/statm to read memory usage\n");
exit(1);
}
unsigned long unused;
unsigned long rss;
if (fscanf(fp, "%ld %ld %ld %ld %ld %ld %ld", &unused, &rss, &unused, &unused, &unused, &unused, &unused) != 7) {
perror("");
exit(1);
}
(void)unused;
fclose(fp);
return rss * (4096 / 1024); // in KiB (not kB)
}
//==============================================================
// LOAD
//==============================================================
inline void load(int wl,
int kt,
int index_type,
std::vector<keytype> &init_keys,
std::vector<keytype> &keys,
std::vector<uint64_t> &values,
std::vector<int> &ranges,
std::vector<int> &ops) {
std::string init_file;
std::string txn_file;
if (kt == RAND_KEY && wl == WORKLOAD_A) {
init_file = "workloads/loada_zipf_int_100M.dat";
txn_file = "workloads/txnsa_zipf_int_100M.dat";
} else if (kt == RAND_KEY && wl == WORKLOAD_C) {
init_file = "workloads/loadc_zipf_int_100M.dat";
txn_file = "workloads/txnsc_zipf_int_100M.dat";
} else if (kt == RAND_KEY && wl == WORKLOAD_E) {
init_file = "workloads/loade_zipf_int_100M.dat";
txn_file = "workloads/txnse_zipf_int_100M.dat";
} else if (kt == MONO_KEY && wl == WORKLOAD_A) {
init_file = "workloads/mono_inc_loada_zipf_int_100M.dat";
txn_file = "workloads/mono_inc_txnsa_zipf_int_100M.dat";
} else if (kt == MONO_KEY && wl == WORKLOAD_C) {
init_file = "workloads/mono_inc_loadc_zipf_int_100M.dat";
txn_file = "workloads/mono_inc_txnsc_zipf_int_100M.dat";
} else if (kt == MONO_KEY && wl == WORKLOAD_E) {
init_file = "workloads/mono_inc_loade_zipf_int_100M.dat";
txn_file = "workloads/mono_inc_txnse_zipf_int_100M.dat";
} else {
fprintf(stderr, "Unknown workload type or key type: %d, %d\n", wl, kt);
exit(1);
}
std::ifstream infile_load(init_file);
std::string op;
keytype key;
int range;
std::string insert("INSERT");
std::string read("READ");
std::string update("UPDATE");
std::string scan("SCAN");
int count = 0;
while ((count < INIT_LIMIT) && infile_load.good()) {
infile_load >> op >> key;
if (op.compare(insert) != 0) {
std::cout << "READING LOAD FILE FAIL!\n";
return;
}
init_keys.push_back(key);
count++;
// If we have reached the max init key limit then just break
if(max_init_key > 0 && count == max_init_key) {
break;
}
}
fprintf(stderr, "Loaded %d keys\n", count);
count = 0;
uint64_t value = 0;
void *base_ptr = malloc(8);
uint64_t base = (uint64_t)(base_ptr);
free(base_ptr);
keytype *init_keys_data = init_keys.data();
if (value_type == 0) {
while (count < INIT_LIMIT) {
value = base + rand();
values.push_back(value);
count++;
}
}
else {
while (count < INIT_LIMIT) {
values.push_back(reinterpret_cast<uint64_t>(init_keys_data+count));
count++;
}
}
// If we do not perform other transactions, we can skip txn file
if(insert_only == true) {
return;
}
// If we also execute transaction then open the
// transacton file here
std::ifstream infile_txn(txn_file);
count = 0;
while ((count < LIMIT) && infile_txn.good()) {
infile_txn >> op >> key;
if (op.compare(insert) == 0) {
ops.push_back(OP_INSERT);
keys.push_back(key);
ranges.push_back(1);
}
else if (op.compare(read) == 0) {
ops.push_back(OP_READ);
keys.push_back(key);
}
else if (op.compare(update) == 0) {
ops.push_back(OP_UPSERT);
keys.push_back(key);
}
else if (op.compare(scan) == 0) {
infile_txn >> range;
ops.push_back(OP_SCAN);
keys.push_back(key);
ranges.push_back(range);
}
else {
std::cout << "UNRECOGNIZED CMD!\n";
return;
}
count++;
}
// Average and variation
long avg = 0, var = 0;
// If it is YSCB-E workload then we compute average and stdvar
if(ranges.size() != 0) {
for(int r : ranges) {
avg += r;
}
avg /= (long)ranges.size();
for(int r : ranges) {
var += ((r - avg) * (r - avg));
}
var /= (long)ranges.size();
fprintf(stderr, "YCSB-E scan Avg length: %ld; Variance: %ld\n",
avg, var);
}
}
//==============================================================
// EXEC
//==============================================================
inline void exec(int wl,
int index_type,
int num_thread,
std::vector<keytype> &init_keys,
std::vector<keytype> &keys,
std::vector<uint64_t> &values,
std::vector<int> &ranges,
std::vector<int> &ops) {
Index<keytype, keycomp> *idx = getInstance<keytype, keycomp>(index_type, key_type);
//WRITE ONLY TEST-----------------
int count = (int)init_keys.size();
fprintf(stderr, "Populating the index with %d keys using %d threads\n", count, num_thread);
#ifdef USE_TBB
tbb::task_scheduler_init init{num_thread};
std::atomic<int> next_thread_id;
next_thread_id.store(0);
auto func = [idx, &init_keys, &values, &next_thread_id](const tbb::blocked_range<size_t>& r) {
size_t start_index = r.begin();
size_t end_index = r.end();
threadinfo *ti = threadinfo::make(threadinfo::TI_MAIN, -1);
int thread_id = next_thread_id.fetch_add(1);
idx->AssignGCID(thread_id);
int gc_counter = 0;
for(size_t i = start_index;i < end_index;i++) {
idx->insert(init_keys[i], values[i], ti);
gc_counter++;
if(gc_counter % 4096 == 0) {
ti->rcu_quiesce();
}
}
ti->rcu_quiesce();
idx->UnregisterThread(thread_id);
return;
};
idx->UpdateThreadLocal(num_thread);
tbb::parallel_for(tbb::blocked_range<size_t>(0, count), func);
idx->UpdateThreadLocal(1);
#else
auto func = [idx, &init_keys, num_thread, &values, index_type] \
(uint64_t thread_id, bool) {
size_t total_num_key = init_keys.size();
size_t key_per_thread = total_num_key / num_thread;
size_t start_index = key_per_thread * thread_id;
size_t end_index = start_index + key_per_thread;
threadinfo *ti = threadinfo::make(threadinfo::TI_MAIN, -1);
int gc_counter = 0;
#ifdef INTERLEAVED_INSERT
for(size_t i = thread_id;i < total_num_key;i += num_thread) {
#else
for(size_t i = start_index;i < end_index;i++) {
#endif
if(index_type == TYPE_SKIPLIST) {
idx->insert(init_keys[start_index + end_index - 1 - i],
values[start_index + end_index - 1 - i],
ti);
} else {
#ifdef BWTREE_USE_DELTA_UPDATE
idx->insert(init_keys[i], values[i], ti);
#else
idx->insert_bwtree_fast(init_keys[i], values[i]);
#endif
}
gc_counter++;
if(gc_counter % 4096 == 0) {
ti->rcu_quiesce();
}
}
ti->rcu_quiesce();
return;
};
if(memory_bandwidth == true) {
PCM_memory::StartMemoryMonitor();
}
if(numa == true) {
PCM_NUMA::StartNUMAMonitor();
}
double start_time = get_now();
StartThreads(idx, num_thread, func, false);
double end_time = get_now();
if(index_type == TYPE_SKIPLIST) {
fprintf(stderr, "SkipList size = %lu\n", idx->GetIndexSize());
fprintf(stderr, "Skiplist avg. steps = %f\n", (double)skiplist_total_steps / (double)init_keys.size());
}
if(memory_bandwidth == true) {
PCM_memory::EndMemoryMonitor();
}
if(numa == true) {
PCM_NUMA::EndNUMAMonitor();
}
#endif
double tput = count / (end_time - start_time) / 1000000; //Mops/sec
std::cout << "\033[1;32m";
std::cout << "insert " << tput << "\033[0m" << "\n";
// Only execute consolidation if BwTree delta chain is used
#ifdef BWTREE_CONSOLIDATE_AFTER_INSERT
fprintf(stderr, "Starting consolidating delta chain on each level\n");
idx->AfterLoadCallback();
#endif
// If the workload only executes load phase then we return here
if(insert_only == true) {
delete idx;
return;
}
//READ/UPDATE/SCAN TEST----------------
int txn_num = GetTxnCount(ops, index_type);
uint64_t sum = 0;
uint64_t s = 0;
if(values.size() < keys.size()) {
fprintf(stderr, "Values array too small\n");
exit(1);
}
fprintf(stderr, "# of Txn: %d\n", txn_num);
// This is used to count how many read misses we have found
std::atomic<size_t> read_miss_counter{}, read_hit_counter{};
read_miss_counter.store(0UL);
read_hit_counter.store(0UL);
auto func2 = [num_thread,
idx,
&read_miss_counter,
&read_hit_counter,
&keys,
&values,
&ranges,
&ops](uint64_t thread_id, bool) {
size_t total_num_op = ops.size();
size_t op_per_thread = total_num_op / num_thread;
size_t start_index = op_per_thread * thread_id;
size_t end_index = start_index + op_per_thread;
std::vector<uint64_t> v;
v.reserve(10);
threadinfo *ti = threadinfo::make(threadinfo::TI_MAIN, -1);
int counter = 0;
for(size_t i = start_index;i < end_index;i++) {
int op = ops[i];
if (op == OP_INSERT) { //INSERT
idx->insert(keys[i], values[i], ti);
}
else if (op == OP_READ) { //READ
v.clear();
#ifdef BWTREE_USE_MAPPING_TABLE
idx->find(keys[i], &v, ti);
#else
idx->find_bwtree_fast(keys[i], &v);
#endif
// If we count read misses then increment the
// counter here if the vetor is empty
#ifdef COUNT_READ_MISS
if(v.size() == 0UL) {
read_miss_counter.fetch_add(1);
} else {
read_hit_counter.fetch_add(1);
}
#endif
}
else if (op == OP_UPSERT) { //UPDATE
idx->upsert(keys[i], reinterpret_cast<uint64_t>(&keys[i]), ti);
}
else if (op == OP_SCAN) { //SCAN
idx->scan(keys[i], ranges[i], ti);
}
counter++;
if(counter % 4096 == 0) {
ti->rcu_quiesce();
}
}
// Perform GC after all operations
ti->rcu_quiesce();
return;
};
if(memory_bandwidth == true) {
PCM_memory::StartMemoryMonitor();
}
if(numa == true) {
PCM_NUMA::StartNUMAMonitor();
}
start_time = get_now();
StartThreads(idx, num_thread, func2, false);
end_time = get_now();
if(memory_bandwidth == true) {
PCM_memory::EndMemoryMonitor();
}
if(numa == true) {
PCM_NUMA::EndNUMAMonitor();
}
// Print out how many reads have missed in the index (do not have a value)
#ifdef COUNT_READ_MISS
fprintf(stderr,
" Read misses: %lu; Read hits: %lu\n",
read_miss_counter.load(),
read_hit_counter.load());
#endif
tput = txn_num / (end_time - start_time) / 1000000; //Mops/sec
std::cout << "sum = " << sum << "\n";
std::cout << "\033[1;31m";
if (wl == WORKLOAD_A) {
std::cout << "read/update " << (tput + (sum - sum));
} else if (wl == WORKLOAD_C) {
std::cout << "read " << (tput + (sum - sum));
} else if (wl == WORKLOAD_E) {
std::cout << "insert/scan " << (tput + (sum - sum));
} else {
fprintf(stderr, "Unknown workload type: %d\n", wl);
exit(1);
}
std::cout << "\033[0m" << "\n";
if(index_type == TYPE_SKIPLIST) {
fprintf(stderr, "SkipList size = %lu\n", idx->GetIndexSize());
fprintf(stderr, "Skiplist avg. steps = %f\n", (double)skiplist_total_steps / (double)init_keys.size());
}
delete idx;
return;
}
/*
* run_rdtsc_benchmark() - This function runs the RDTSC benchmark which is a high
* contention insert-only benchmark
*
* Note that key num is the total key num
*/
void run_rdtsc_benchmark(int index_type, int thread_num, int key_num) {
Index<keytype, keycomp> *idx = getInstance<keytype, keycomp>(index_type, key_type);
auto func = [idx, thread_num, key_num](uint64_t thread_id, bool) {
size_t key_per_thread = key_num / thread_num;
threadinfo *ti = threadinfo::make(threadinfo::TI_MAIN, -1);
uint64_t *values = new uint64_t[key_per_thread];
int gc_counter = 0;
for(size_t i = 0;i < key_per_thread;i++) {
// Note that RDTSC may return duplicated keys from different cores
// to counter this we combine RDTSC with thread IDs to make it unique
// The counter value on a single core is always unique, though
uint64_t key = (Rdtsc() << 6) | thread_id;
values[i] = key;
//fprintf(stderr, "%lx\n", key);
idx->insert(key, reinterpret_cast<uint64_t>(values + i), ti);
gc_counter++;
if(gc_counter % 4096 == 0) {
ti->rcu_quiesce();
}
}
ti->rcu_quiesce();
delete [] values;
return;
};
if(numa == true) {
PCM_NUMA::StartNUMAMonitor();
}
double start_time = get_now();
StartThreads(idx, thread_num, func, false);
double end_time = get_now();
if(numa == true) {
PCM_NUMA::EndNUMAMonitor();
}
// Only execute consolidation if BwTree delta chain is used
#ifdef BWTREE_CONSOLIDATE_AFTER_INSERT
idx->AfterLoadCallback();
#endif
double tput = key_num * 1.0 / (end_time - start_time) / 1000000; //Mops/sec
std::cout << "insert " << tput << "\n";
return;
}
int main(int argc, char *argv[]) {
if (argc < 5) {
std::cout << "Usage:\n";
std::cout << "1. workload type: a, c, e, none\n";
std::cout << " \"none\" type means we just load the file and exit. \n"
"This serves as the base line for microbenchamrks\n";
std::cout << "2. key distribution: rand, mono\n";
std::cout << "3. index type: bwtree skiplist masstree artolc btreeolc btreertm\n";
std::cout << "4. number of threads (integer)\n";
std::cout << " --hyper: Whether to pin all threads on NUMA node 0\n";
std::cout << " --mem: Whether to monitor memory access\n";
std::cout << " --numa: Whether to monitor NUMA throughput\n";
std::cout << " --insert-only: Whether to only execute insert operations\n";
return 1;
}
// Then read the workload type
int wl;
if (strcmp(argv[1], "a") == 0) {
wl = WORKLOAD_A;
} else if (strcmp(argv[1], "c") == 0) {
wl = WORKLOAD_C;
} else if (strcmp(argv[1], "e") == 0) {
wl = WORKLOAD_E;
} else {
fprintf(stderr, "Unknown workload: %s\n", argv[1]);
exit(1);
}
// Then read key type
int kt;
if (strcmp(argv[2], "rand") == 0) {
kt = RAND_KEY;
} else if (strcmp(argv[2], "mono") == 0) {
kt = MONO_KEY;
} else if (strcmp(argv[2], "rdtsc") == 0) {
kt = RDTSC_KEY;
} else {
fprintf(stderr, "Unknown key type: %s\n", argv[2]);
exit(1);
}
int index_type;
if (strcmp(argv[3], "bwtree") == 0)
index_type = TYPE_BWTREE;
else if (strcmp(argv[3], "masstree") == 0)
index_type = TYPE_MASSTREE;
else if (strcmp(argv[3], "artolc") == 0)
index_type = TYPE_ARTOLC;
else if (strcmp(argv[3], "btreeolc") == 0)
index_type = TYPE_BTREEOLC;
else if (strcmp(argv[3], "skiplist") == 0)
index_type = TYPE_SKIPLIST;
else if (strcmp(argv[3], "btreertm") == 0)
index_type = TYPE_BTREERTM;
else if (strcmp(argv[3], "none") == 0)
// This is a special type used for measuring base cost (i.e.
// only loading the workload files but do not invoke the index)
index_type = TYPE_NONE;
else {
fprintf(stderr, "Unknown index type: %d\n", index_type);
exit(1);
}
// Then read number of threads using command line
int num_thread = atoi(argv[4]);
if(num_thread < 1 || num_thread > 40) {
fprintf(stderr, "Do not support %d threads\n", num_thread);
exit(1);
} else {
fprintf(stderr, "Number of threads: %d\n", num_thread);
}
// Then read all remianing arguments
int repeat_counter = 1;
char **argv_end = argv + argc;
for(char **v = argv + 5;v != argv_end;v++) {
if(strcmp(*v, "--hyper") == 0) {
// Enable hyoerthreading for scheduling threads
hyperthreading = true;
} else if(strcmp(*v, "--mem") == 0) {
// Enable memory bandwidth measurement
memory_bandwidth = true;
} else if(strcmp(*v, "--numa") == 0) {
numa = true;
} else if(strcmp(*v, "--insert-only") == 0) {
insert_only = true;
} else if(strcmp(*v, "--repeat") == 0) {
// If we repeat, then exec() will be called for 5 times
repeat_counter = 5;
} else if(strcmp(*v, "--max-init-key") == 0) {
max_init_key = atoll(*(v + 1));
if(max_init_key <= 0) {
fprintf(stderr, "Illegal maximum init keys: %ld\n", max_init_key);
exit(1);
}
// Ignore the next argument
v++;
} else {
fprintf(stderr, "Unknown switch: %s\n", *v);
exit(1);
}
}
if(max_init_key != -1) {
fprintf(stderr, "Maximum init keys: %ld\n", max_init_key);
fprintf(stderr, " NOTE: Memory is not affected in this case\n");
}
#ifdef COUNT_READ_MISS
fprintf(stderr, " Counting read misses\n");
#endif
#ifdef BWTREE_CONSOLIDATE_AFTER_INSERT
fprintf(stderr, " BwTree will considate after insert phase\n");
#endif
#ifdef USE_TBB
fprintf(stderr, " Using Intel TBB to run concurrent tasks\n");
#endif
#ifdef INTERLEAVED_INSERT
fprintf(stderr, " Interleaved insert\n");
#endif
#ifdef BWTREE_COLLECT_STATISTICS
fprintf(stderr, " BwTree will collect statistics\n");
#endif
fprintf(stderr, "Leaf delta chain threshold: %d; Inner delta chain threshold: %d\n",
LEAF_DELTA_CHAIN_LENGTH_THRESHOLD,
INNER_DELTA_CHAIN_LENGTH_THRESHOLD);
#ifndef BWTREE_USE_MAPPING_TABLE
fprintf(stderr, " BwTree does not use mapping table\n");
if(wl != WORKLOAD_C) {
fprintf(stderr, "Could only use workload C\n");
exit(1);
}
if(index_type != TYPE_BWTREE) {
fprintf(stderr, "Could only use BwTree\n");
exit(1);
}
#endif
#ifndef BWTREE_USE_CAS
fprintf(stderr, " BwTree does not use CAS\n");
#endif
#ifndef BWTREE_USE_DELTA_UPDATE
fprintf(stderr, " BwTree does not use delta update\n");
if(index_type != TYPE_BWTREE) {
fprintf(stderr, "Could only use BwTree\n");
}
#endif
#ifdef USE_OLD_EPOCH
fprintf(stderr, " BwTree uses old epoch\n");
#endif
// If we do not interleave threads on two sockets then this will be printed
if(hyperthreading == true) {
fprintf(stderr, " Hyperthreading for thread 10 - 19, 30 - 39\n");
}
if(repeat_counter != 1) {
fprintf(stderr, " Repeat for %d times (NOTE: Memory number may not be correct)\n",
repeat_counter);
}
if(memory_bandwidth == true) {
if(geteuid() != 0) {
fprintf(stderr, "Please run the program as root in order to measure memory bandwidth\n");
exit(1);
}
fprintf(stderr, " Measuring memory bandwidth\n");
PCM_memory::InitMemoryMonitor();
}
if(numa == true) {
if(geteuid() != 0) {
fprintf(stderr, "Please run the program as root in order to measure NUMA operations\n");
exit(1);
}
fprintf(stderr, " Measuring NUMA operations\n");
// Call init here to avoid calling it mutiple times
PCM_NUMA::InitNUMAMonitor();
}
if(insert_only == true) {
fprintf(stderr, "Program will exit after insert operation\n");
}
fprintf(stderr, " BTree element pair count: %lu\n",
(uint64_t)btreeolc::BTreeLeaf<uint64_t, uint64_t>::maxEntries);
// If the key type is RDTSC we just run the special function
if(kt != RDTSC_KEY) {
std::vector<keytype> init_keys;
std::vector<keytype> keys;
std::vector<uint64_t> values;
std::vector<int> ranges;
std::vector<int> ops; //INSERT = 0, READ = 1, UPDATE = 2
init_keys.reserve(50000000);
keys.reserve(10000000);
values.reserve(10000000);
ranges.reserve(10000000);
ops.reserve(10000000);
memset(&init_keys[0], 0x00, 50000000 * sizeof(keytype));
memset(&keys[0], 0x00, 10000000 * sizeof(keytype));
memset(&values[0], 0x00, 10000000 * sizeof(uint64_t));
memset(&ranges[0], 0x00, 10000000 * sizeof(int));
memset(&ops[0], 0x00, 10000000 * sizeof(int));
load(wl, kt, index_type, init_keys, keys, values, ranges, ops);
printf("Finished loading workload file (mem = %lu)\n", MemUsage());
if(index_type != TYPE_NONE) {
// Then repeat executing the same workload
while(repeat_counter > 0) {
exec(wl, index_type, num_thread, init_keys, keys, values, ranges, ops);
repeat_counter--;
printf("Finished running benchmark (mem = %lu)\n", MemUsage());
}
} else {
fprintf(stderr, "Type None is selected - no execution phase\n");
}
} else {
fprintf(stderr, "Running RDTSC benchmark...\n");
run_rdtsc_benchmark(index_type, num_thread, 50 * 1000 * 1000);
}
exit_cleanup();
return 0;
}