diff --git a/Bench.cpp b/Bench.cpp index e47f5ab..57a4d45 100644 --- a/Bench.cpp +++ b/Bench.cpp @@ -543,8 +543,8 @@ private: }; struct SkipListConflictSet { - int64_t oldestVersion; - SkipListConflictSet(int64_t oldestVersion) : oldestVersion(oldestVersion) {} + SkipListConflictSet(int64_t oldestVersion) + : oldestVersion(oldestVersion), skipList(oldestVersion) {} void check(const ConflictSet::ReadRange *reads, ConflictSet::Result *results, int count) const { Arena arena; @@ -594,29 +594,37 @@ struct SkipListConflictSet { } private: + int64_t oldestVersion; SkipList skipList; }; } // namespace -constexpr int kNumKeys = 100000; +constexpr int kNumKeys = 1000000; constexpr int kOpsPerTx = 100; constexpr int kPrefixLen = 0; std::span makeKey(Arena &arena, int index) { + auto result = std::span{new (arena) uint8_t[4 + kPrefixLen], 4 + kPrefixLen}; index = __builtin_bswap32(index); memset(result.data(), 0, kPrefixLen); memcpy(result.data() + kPrefixLen, &index, 4); + + // auto result = + // std::span{new (arena) uint8_t[32], 32}; + // for (int i = 0; i < 32; ++i) { + // result[i] = index & (1 << (31 - i)) ? '1' : '0'; + // } + return result; } template void benchConflictSet(const std::string &name) { ankerl::nanobench::Bench bench; - bench.minEpochIterations(1000); ConflictSet_ cs{0}; bench.batch(kOpsPerTx); @@ -650,8 +658,6 @@ template void benchConflictSet(const std::string &name) { }; auto points = set, Less>(arena); - // Two points for each range read, one for each point read, and one for each - // point write while (points.size() < kOpsPerTx * 2 + 1) { // TODO don't use rand? points.insert(makeKey(arena, rand() % kNumKeys)); @@ -660,21 +666,21 @@ template void benchConflictSet(const std::string &name) { // Make short-circuiting non-trivial { std::vector writes; - writes.reserve(kNumKeys); - for (int i = 0; i < kNumKeys; ++i) { - auto key = makeKey(arena, i); - if (points.find(key) != points.end()) { - continue; - } - ConflictSet::WriteRange conflict; - conflict.begin.p = key.data(); - conflict.begin.len = key.size(); - conflict.end.len = 0; - conflict.writeVersion = version + 1; - writes.push_back(conflict); + auto iter = points.begin(); + ++iter; // Complement of the set we'll be reading with range reads. Almost. + for (int i = 0; i < kOpsPerTx; ++i) { + auto begin = *iter++; + auto end = *iter++; + ConflictSet::WriteRange w; + w.begin.p = begin.data(); + w.begin.len = begin.size(); + w.end.p = end.data(); + w.end.len = end.size(); + w.writeVersion = version + 1; + writes.push_back(w); } - cs.addWrites(writes.data(), writes.size()); ++version; + cs.addWrites(writes.data(), kOpsPerTx); } { diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 317fce0..c0707b9 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -894,9 +894,7 @@ bytes: bool checkRangeRead(Node *n, const std::span begin, const std::span end, int64_t readVersion, Arena &arena) { - auto left = FirstGeqStepwise{n, begin}; - while (!left.step()) - ; + auto left = firstGeq(n, begin); #if DEBUG_VERBOSE && !defined(NDEBUG) fprintf(stderr, "firstGeq for `%s' got `%s'\n", printable(begin).c_str(),