|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <netdb.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
@@ -37,41 +38,20 @@ std::string makeKey(int64_t num, int suffixLen) {
|
|
|
|
|
|
|
|
|
|
void workload(weaselab::ConflictSet *cs) {
|
|
|
|
|
int64_t version = kWindowSize;
|
|
|
|
|
for (int i = 0; i < kNumPrefixes; ++i) {
|
|
|
|
|
for (int j = 0; j < 50; ++j) {
|
|
|
|
|
weaselab::ConflictSet::WriteRange wr;
|
|
|
|
|
auto k = makeKey(i, j);
|
|
|
|
|
wr.begin.p = (const uint8_t *)k.data();
|
|
|
|
|
wr.begin.len = k.size();
|
|
|
|
|
wr.end.len = 0;
|
|
|
|
|
cs->addWrites(&wr, 1, version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
++version;
|
|
|
|
|
for (int i = 0; i < kNumPrefixes; ++i) {
|
|
|
|
|
weaselab::ConflictSet::WriteRange wr;
|
|
|
|
|
auto k = makeKey(i, 50);
|
|
|
|
|
wr.begin.p = (const uint8_t *)k.data();
|
|
|
|
|
wr.begin.len = k.size();
|
|
|
|
|
wr.end.len = 0;
|
|
|
|
|
cs->addWrites(&wr, 1, version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr int kNumReads = 1;
|
|
|
|
|
std::vector<weaselab::ConflictSet::Result> results(kNumReads);
|
|
|
|
|
constexpr int kNumWrites = 16;
|
|
|
|
|
for (;; transactions.fetch_add(1, std::memory_order_relaxed)) {
|
|
|
|
|
std::vector<std::string> keys(kNumReads);
|
|
|
|
|
for (auto &k : keys) {
|
|
|
|
|
k = makeKey(rand() % kNumPrefixes, 49);
|
|
|
|
|
std::vector<std::string> keys;
|
|
|
|
|
std::vector<weaselab::ConflictSet::WriteRange> writes;
|
|
|
|
|
for (int i = 0; i < kNumWrites; ++i) {
|
|
|
|
|
keys.push_back(makeKey(rand() % kNumPrefixes, rand() % 50));
|
|
|
|
|
}
|
|
|
|
|
std::vector<weaselab::ConflictSet::ReadRange> reads(kNumReads);
|
|
|
|
|
for (int i = 0; i < reads.size(); ++i) {
|
|
|
|
|
reads[i].begin.p = (const uint8_t *)(keys[i].data());
|
|
|
|
|
reads[i].begin.len = keys[i].size();
|
|
|
|
|
reads[i].end.len = 0;
|
|
|
|
|
reads[i].readVersion = version - 1;
|
|
|
|
|
for (int i = 0; i < kNumWrites; ++i) {
|
|
|
|
|
writes.push_back({{(const uint8_t *)keys[i].data(), int(keys[i].size())},
|
|
|
|
|
{nullptr, 0}});
|
|
|
|
|
}
|
|
|
|
|
cs->check(reads.data(), results.data(), kNumReads);
|
|
|
|
|
cs->addWrites(writes.data(), writes.size(), version);
|
|
|
|
|
cs->setOldestVersion(version - kWindowSize);
|
|
|
|
|
++version;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|