-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench_readonly.cc
115 lines (102 loc) · 3.61 KB
/
bench_readonly.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
#include "bench_readonly.h"
#include "allocator.h"
#include "logging.h"
#include "memcached_kv.h"
#include "mig.h"
#include "rdma_control.h"
#include "stat.h"
namespace slope {
namespace bench {
namespace readonly {
void run(std::string self_id, std::vector<std::string> peers,
std::unique_ptr<slope::keyvalue::KeyValuePrefixMiddleware> kv,
std::map<std::string, std::string> params) {
std::sort(peers.begin(), peers.end());
auto cp = std::make_unique<slope::control::RdmaControlPlane<MigVectorB>>(
self_id, peers, std::move(kv));
assert(params.size() == 1);
size_t num_pages = std::stoul(params[num_pages_param]);
assert(num_pages > 0);
slope::stat::set_param_meta(num_pages_param, params[num_pages_param]);
size_t num_entries =
(num_pages - 1) * slope::alloc::page_size / sizeof(Payload) + 1;
if (cp->self_name() == cp->cluster_nodes().front()) {
debout("start testdrive_migrate");
slope::mig_ptr<MigVectorB> ptr;
debout("finished creating a vector of int of size 0");
{
debout("acquiring a context for adding elements to the vector");
auto ctx = ptr.create_context();
deb(num_entries);
ptr.get()->resize(num_entries);
}
std::iota(ptr.get()->begin(), ptr.get()->end(), 0);
deb(num_entries);
deb(ptr.get()->size());
deb(*ptr.get());
for (auto it : ptr.get_chunks()) {
std::stringstream out;
out << std::showbase << std::internal << std::setfill('0') << " @"
<< std::hex << std::setw(16) << it.first;
out << " " << it.second;
debout(out.str());
}
debout("vector contents:");
deb(*ptr.get());
debout("start the migration");
deb(cp->cluster_nodes());
slope::stat::add_value(slope::stat::key::operation, "call: init_migration");
auto operation = cp->init_migration(cp->cluster_nodes()[1], ptr);
slope::stat::add_value(slope::stat::key::operation,
"start: calling try_finish_write");
while (true) {
if (operation->try_finish_write()) {
break;
}
}
slope::stat::add_value(slope::stat::key::operation,
"finish: calling try_finish_write");
slope::stat::add_value(slope::stat::key::operation,
"start: calling try_finish_read");
while (true) {
if (operation->try_finish_read()) {
break;
}
}
slope::stat::add_value(slope::stat::key::operation,
"finish: calling try_finish_read");
operation->collect();
slope::stat::add_value(slope::stat::key::operation, "finish: collect");
} else {
// cp->simple_recv();
while (true) {
auto migrated_ptr = cp->poll_migrate();
debout("null");
if (migrated_ptr.get() != nullptr) {
debout("returned");
deb((*migrated_ptr.get()));
slope::stat::add_value(slope::stat::key::operation,
"recieved: object ptr");
#ifdef SLOPE_DEBUG
for (auto it : migrated_ptr.get_chunks()) {
std::stringstream out;
out << std::showbase << std::internal << std::setfill('0') << " @"
<< std::hex << std::setw(16) << it.first;
out << " " << it.second;
debout(out.str());
}
#endif
slope::stat::add_value(slope::stat::key::operation,
"call: collect_pages");
migrated_ptr.collect_pages();
slope::stat::add_value(slope::stat::key::operation,
"finish: collect_pages");
break;
}
}
debout("done");
}
}
} // namespace readonly
} // namespace bench
} // namespace slope