Compare commits
14 Commits
e4a77c88d8
...
main
Author | SHA1 | Date | |
---|---|---|---|
6abd8139f0 | |||
57cceaf3b7 | |||
39273424c1 | |||
c4c269ab94 | |||
fcb881f408 | |||
b2ce851d56 | |||
e11ee26332 | |||
0af75f5e9c | |||
43ba21329b | |||
3e9c69e857 | |||
edb76feadf | |||
2eea70f063 | |||
be3032e2f3 | |||
b34d559c02 |
130
Bench.cpp
130
Bench.cpp
@@ -3,6 +3,34 @@
|
|||||||
|
|
||||||
#include <nanobench.h>
|
#include <nanobench.h>
|
||||||
|
|
||||||
|
void iterBench(const Facade &facade, int64_t version,
|
||||||
|
const std::string &context) {
|
||||||
|
ankerl::nanobench::Bench bench;
|
||||||
|
bench.minEpochIterations(10000);
|
||||||
|
|
||||||
|
const auto begin = facade.versioned.begin(version);
|
||||||
|
const auto end = facade.versioned.end(version);
|
||||||
|
auto iter = begin;
|
||||||
|
|
||||||
|
bench.run("*iter (" + context + ")", [&] { bench.doNotOptimizeAway(*iter); });
|
||||||
|
|
||||||
|
iter = begin;
|
||||||
|
bench.run("++iter (" + context + ")", [&] {
|
||||||
|
++iter;
|
||||||
|
if (iter == end) {
|
||||||
|
iter = begin;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
iter = end;
|
||||||
|
bench.run("--iter (" + context + ")", [&] {
|
||||||
|
--iter;
|
||||||
|
if (iter == begin) {
|
||||||
|
iter = end;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void monotonicallyIncreasing() {
|
void monotonicallyIncreasing() {
|
||||||
constexpr int kWindow = 1000;
|
constexpr int kWindow = 1000;
|
||||||
ankerl::nanobench::Bench bench;
|
ankerl::nanobench::Bench bench;
|
||||||
@@ -25,27 +53,7 @@ void monotonicallyIncreasing() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const auto v = facade.getVersion() - kWindow / 2;
|
const auto v = facade.getVersion() - kWindow / 2;
|
||||||
const auto begin = facade.versioned.begin(v);
|
iterBench(facade, v, "monotonically increasing");
|
||||||
const auto end = facade.versioned.end(v);
|
|
||||||
auto iter = begin;
|
|
||||||
|
|
||||||
bench.run("*iter", [&] { bench.doNotOptimizeAway(*iter); });
|
|
||||||
|
|
||||||
iter = begin;
|
|
||||||
bench.run("++iter", [&] {
|
|
||||||
++iter;
|
|
||||||
if (iter == end) {
|
|
||||||
iter = begin;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
iter = end;
|
|
||||||
bench.run("--iter", [&] {
|
|
||||||
--iter;
|
|
||||||
if (iter == begin) {
|
|
||||||
iter = end;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bench.run("begin", [&] { facade.versioned.begin(v); });
|
bench.run("begin", [&] { facade.versioned.begin(v); });
|
||||||
|
|
||||||
@@ -56,6 +64,27 @@ void monotonicallyIncreasing() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
bench.run("end", [&] { facade.versioned.end(v); });
|
bench.run("end", [&] { facade.versioned.end(v); });
|
||||||
|
|
||||||
|
{
|
||||||
|
ankerl::nanobench::Bench bench;
|
||||||
|
bench.batch(kWindow);
|
||||||
|
|
||||||
|
bench.run("Facade monotonically-increasing read forward", [&]() {
|
||||||
|
if (facade.viewAt(facade.getVersion())
|
||||||
|
.rangeRead(String(), String({0xff}), kWindow, false)
|
||||||
|
.size() != kWindow) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bench.run("Facade monotonically-increasing read reverse", [&]() {
|
||||||
|
if (facade.viewAt(facade.getVersion())
|
||||||
|
.rangeRead(String(), String({0xff}), kWindow, true)
|
||||||
|
.size() != kWindow) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bulkFirstGeq() {
|
void bulkFirstGeq() {
|
||||||
@@ -103,7 +132,66 @@ void bulkFirstGeq() {
|
|||||||
[&] { versionedMap.firstGeq(keys, iterators, kNumQueries); });
|
[&] { versionedMap.firstGeq(keys, iterators, kNumQueries); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void facadeVersionedOnlyRead() {
|
||||||
|
Facade facade{0};
|
||||||
|
constexpr int kNumKeys = 1000;
|
||||||
|
ankerl::nanobench::Bench bench;
|
||||||
|
bench.batch(kNumKeys);
|
||||||
|
|
||||||
|
const int64_t beginBytes = __builtin_bswap64(0);
|
||||||
|
const int64_t endBytes = __builtin_bswap64(kNumKeys);
|
||||||
|
const String begin{(const uint8_t *)&beginBytes, 8};
|
||||||
|
const String end{(const uint8_t *)&endBytes, 8};
|
||||||
|
|
||||||
|
// Insert clear in entire range, so that all reads are served from versioned,
|
||||||
|
// logically and hopefully physically.
|
||||||
|
{
|
||||||
|
weaselab::VersionedMap::Mutation mutations[] = {
|
||||||
|
{begin.data(), int(begin.size()), end.data(), int(end.size()),
|
||||||
|
weaselab::VersionedMap::Clear},
|
||||||
|
};
|
||||||
|
facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]),
|
||||||
|
facade.getVersion() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Arena arena;
|
||||||
|
weaselab::VersionedMap::Mutation *mutations =
|
||||||
|
new (arena) weaselab::VersionedMap::Mutation[kNumKeys];
|
||||||
|
for (int i = 0; i < kNumKeys; ++i) {
|
||||||
|
const int64_t k = __builtin_bswap64(i);
|
||||||
|
uint8_t *buf = new (arena) uint8_t[8];
|
||||||
|
memcpy(buf, &k, 8);
|
||||||
|
mutations[i] = {buf, 8, buf, 8, weaselab::VersionedMap::Set};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add keys
|
||||||
|
facade.addMutations(mutations, kNumKeys, facade.getVersion() + 1);
|
||||||
|
|
||||||
|
// Populate the unversioned map
|
||||||
|
facade.addMutations(mutations, kNumKeys, facade.getVersion() + 1);
|
||||||
|
facade.setOldestVersion(facade.getVersion() - 1, /*force*/ true);
|
||||||
|
|
||||||
|
iterBench(facade, facade.getVersion(), "adjacent sets/clears");
|
||||||
|
|
||||||
|
bench.run("Facade versioned-only read forward", [&]() {
|
||||||
|
if (facade.viewAt(facade.getVersion())
|
||||||
|
.rangeRead(begin, end, kNumKeys, false)
|
||||||
|
.size() != kNumKeys) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bench.run("Facade versioned-only read reverse", [&]() {
|
||||||
|
if (facade.viewAt(facade.getVersion())
|
||||||
|
.rangeRead(begin, end, kNumKeys, true)
|
||||||
|
.size() != kNumKeys) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
monotonicallyIncreasing();
|
monotonicallyIncreasing();
|
||||||
bulkFirstGeq();
|
bulkFirstGeq();
|
||||||
|
facadeVersionedOnlyRead();
|
||||||
}
|
}
|
||||||
|
87
Facade.h
87
Facade.h
@@ -53,12 +53,13 @@ struct Facade {
|
|||||||
do {
|
do {
|
||||||
--iter;
|
--iter;
|
||||||
auto m = *iter;
|
auto m = *iter;
|
||||||
const auto mBegin =
|
auto mBegin = weaselab::VersionedMap::Key{m.param1, m.param1Len};
|
||||||
weaselab::VersionedMap::Key{m.param1, m.param1Len};
|
auto mEnd =
|
||||||
const auto mEnd =
|
|
||||||
m.type == weaselab::VersionedMap::Set || m.param2Len == 0
|
m.type == weaselab::VersionedMap::Set || m.param2Len == 0
|
||||||
? weaselab::VersionedMap::Key{m.param1, m.param1Len + 1}
|
? weaselab::VersionedMap::Key{m.param1, m.param1Len + 1}
|
||||||
: weaselab::VersionedMap::Key{m.param2, m.param2Len};
|
: weaselab::VersionedMap::Key{m.param2, m.param2Len};
|
||||||
|
|
||||||
|
// Read from unversioned down to mEnd
|
||||||
if (unversionedIter != beginIter) {
|
if (unversionedIter != beginIter) {
|
||||||
--unversionedIter;
|
--unversionedIter;
|
||||||
for (; unversionedIter->first >= mEnd && limit > 0;
|
for (; unversionedIter->first >= mEnd && limit > 0;
|
||||||
@@ -73,6 +74,12 @@ struct Facade {
|
|||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pointMutation =
|
||||||
|
m.type == weaselab::VersionedMap::Set || m.param2Len == 0;
|
||||||
|
|
||||||
|
// Read from versioned until non-adjacent
|
||||||
|
readVersionedReverse:
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case weaselab::VersionedMap::Set: {
|
case weaselab::VersionedMap::Set: {
|
||||||
result.emplace_back(String(mBegin.p, mBegin.len),
|
result.emplace_back(String(mBegin.p, mBegin.len),
|
||||||
@@ -85,7 +92,31 @@ struct Facade {
|
|||||||
case weaselab::VersionedMap::Clear:
|
case weaselab::VersionedMap::Clear:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m.type == weaselab::VersionedMap::Set || m.param2Len == 0) {
|
|
||||||
|
if (iter != endIter) {
|
||||||
|
--iter;
|
||||||
|
auto tmpM = *iter;
|
||||||
|
const auto tmpMBegin =
|
||||||
|
weaselab::VersionedMap::Key{tmpM.param1, tmpM.param1Len};
|
||||||
|
const auto tmpMEnd =
|
||||||
|
tmpM.type == weaselab::VersionedMap::Set || tmpM.param2Len == 0
|
||||||
|
? weaselab::VersionedMap::Key{tmpM.param1,
|
||||||
|
tmpM.param1Len + 1}
|
||||||
|
: weaselab::VersionedMap::Key{tmpM.param2, tmpM.param2Len};
|
||||||
|
if (tmpMEnd >= mBegin) {
|
||||||
|
// Adjacent with last (temporally) mutation
|
||||||
|
mBegin = tmpMBegin;
|
||||||
|
mEnd = tmpMEnd;
|
||||||
|
m = tmpM;
|
||||||
|
pointMutation = false;
|
||||||
|
goto readVersionedReverse;
|
||||||
|
} else {
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance unversioned iter
|
||||||
|
if (pointMutation) {
|
||||||
if (unversionedIter != facade->unversioned.end() &&
|
if (unversionedIter != facade->unversioned.end() &&
|
||||||
unversionedIter->first < mBegin) {
|
unversionedIter->first < mBegin) {
|
||||||
++unversionedIter;
|
++unversionedIter;
|
||||||
@@ -112,16 +143,17 @@ struct Facade {
|
|||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
auto unversionedIter = facade->unversioned.lower_bound(begin);
|
auto unversionedIter = facade->unversioned.lower_bound(begin);
|
||||||
for (auto iter = versionedIter[0]; iter != versionedIter[1]; ++iter) {
|
for (auto iter = versionedIter[0]; iter != versionedIter[1];) {
|
||||||
auto m = *iter;
|
auto m = *iter;
|
||||||
const auto mBegin =
|
auto mBegin = weaselab::VersionedMap::Key{m.param1, m.param1Len};
|
||||||
weaselab::VersionedMap::Key{m.param1, m.param1Len};
|
auto mEnd =
|
||||||
const auto mEnd =
|
|
||||||
m.type == weaselab::VersionedMap::Set || m.param2Len == 0
|
m.type == weaselab::VersionedMap::Set || m.param2Len == 0
|
||||||
? weaselab::VersionedMap::Key{m.param1, m.param1Len + 1}
|
? weaselab::VersionedMap::Key{m.param1, m.param1Len + 1}
|
||||||
: weaselab::VersionedMap::Key{m.param2, m.param2Len};
|
: weaselab::VersionedMap::Key{m.param2, m.param2Len};
|
||||||
|
|
||||||
|
// Read from unversioned up to mBegin
|
||||||
for (; unversionedIter != facade->unversioned.end() &&
|
for (; unversionedIter != facade->unversioned.end() &&
|
||||||
(unversionedIter->first <=> mBegin) < 0 && limit > 0;) {
|
unversionedIter->first < mBegin && limit > 0;) {
|
||||||
result.push_back(*unversionedIter);
|
result.push_back(*unversionedIter);
|
||||||
--limit;
|
--limit;
|
||||||
++unversionedIter;
|
++unversionedIter;
|
||||||
@@ -129,6 +161,12 @@ struct Facade {
|
|||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pointMutation =
|
||||||
|
m.type == weaselab::VersionedMap::Set || m.param2Len == 0;
|
||||||
|
|
||||||
|
// Read from versioned until non-adjacent
|
||||||
|
readVersionedForward:
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case weaselab::VersionedMap::Set: {
|
case weaselab::VersionedMap::Set: {
|
||||||
result.emplace_back(String(mBegin.p, mBegin.len),
|
result.emplace_back(String(mBegin.p, mBegin.len),
|
||||||
@@ -141,19 +179,42 @@ struct Facade {
|
|||||||
case weaselab::VersionedMap::Clear:
|
case weaselab::VersionedMap::Clear:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m.type == weaselab::VersionedMap::Set || m.param2Len == 0) {
|
++iter;
|
||||||
|
if (iter != versionedIter[1]) {
|
||||||
|
auto tmpM = *iter;
|
||||||
|
if (weaselab::VersionedMap::Key{tmpM.param1, tmpM.param1Len} <=
|
||||||
|
mEnd) {
|
||||||
|
// Adjacent with last mutation
|
||||||
|
mBegin = weaselab::VersionedMap::Key{tmpM.param1, tmpM.param1Len};
|
||||||
|
mEnd = tmpM.type == weaselab::VersionedMap::Set ||
|
||||||
|
tmpM.param2Len == 0
|
||||||
|
? weaselab::VersionedMap::Key{tmpM.param1,
|
||||||
|
tmpM.param1Len + 1}
|
||||||
|
: weaselab::VersionedMap::Key{tmpM.param2,
|
||||||
|
tmpM.param2Len};
|
||||||
|
m = tmpM;
|
||||||
|
pointMutation = false;
|
||||||
|
goto readVersionedForward;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance unversioned iter
|
||||||
|
if (pointMutation) {
|
||||||
|
// Point mutation
|
||||||
if (unversionedIter != facade->unversioned.end() &&
|
if (unversionedIter != facade->unversioned.end() &&
|
||||||
(unversionedIter->first <=> mBegin) == 0) {
|
unversionedIter->first <= mBegin) {
|
||||||
++unversionedIter;
|
++unversionedIter;
|
||||||
}
|
}
|
||||||
assert(unversionedIter ==
|
assert(unversionedIter ==
|
||||||
facade->unversioned.lower_bound(String(mEnd.p, mEnd.len)));
|
facade->unversioned.lower_bound(String(mEnd.p, mEnd.len)));
|
||||||
} else {
|
} else {
|
||||||
|
// Range mutation
|
||||||
unversionedIter =
|
unversionedIter =
|
||||||
facade->unversioned.lower_bound(String(mEnd.p, mEnd.len));
|
facade->unversioned.lower_bound(String(mEnd.p, mEnd.len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finish reading from unversioned
|
||||||
for (; unversionedIter != facade->unversioned.end() &&
|
for (; unversionedIter != facade->unversioned.end() &&
|
||||||
unversionedIter->first < end && limit > 0;
|
unversionedIter->first < end && limit > 0;
|
||||||
++unversionedIter) {
|
++unversionedIter) {
|
||||||
@@ -178,15 +239,17 @@ struct Facade {
|
|||||||
versioned.addMutations(mutations, numMutations, version);
|
versioned.addMutations(mutations, numMutations, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOldestVersion(int64_t version) {
|
void setOldestVersion(int64_t version, bool force = false) {
|
||||||
// Don't scan and apply mutations every time setOldestVersion is called.
|
// Don't scan and apply mutations every time setOldestVersion is called.
|
||||||
|
|
||||||
oldestVersion = version;
|
oldestVersion = version;
|
||||||
|
if (!force) {
|
||||||
if (version >= nextPurgeVersion) {
|
if (version >= nextPurgeVersion) {
|
||||||
nextPurgeVersion = versioned.getVersion();
|
nextPurgeVersion = versioned.getVersion();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto iter = versioned.begin(version), end = versioned.end(version);
|
for (auto iter = versioned.begin(version), end = versioned.end(version);
|
||||||
iter != end; ++iter) {
|
iter != end; ++iter) {
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
#include "VersionedMap.h"
|
#include "VersionedMap.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
inline weaselab::VersionedMap::Key operator"" _k(const char *str, size_t size) {
|
inline weaselab::VersionedMap::Key operator""_k(const char *str, size_t size) {
|
||||||
return {reinterpret_cast<const uint8_t *>(str), int(size)};
|
return {reinterpret_cast<const uint8_t *>(str), int(size)};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline String operator"" _s(const char *str, size_t size) {
|
inline String operator""_s(const char *str, size_t size) {
|
||||||
return String{reinterpret_cast<const uint8_t *>(str), size};
|
return String{reinterpret_cast<const uint8_t *>(str), size};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -393,7 +393,7 @@ inline Random seededRandom() {
|
|||||||
return Random{seed[0], seed[1]};
|
return Random{seed[0], seed[1]};
|
||||||
}
|
}
|
||||||
|
|
||||||
static thread_local Random gRandom = seededRandom();
|
inline thread_local Random gRandom = seededRandom();
|
||||||
|
|
||||||
// ==================== END RANDOM IMPL ====================
|
// ==================== END RANDOM IMPL ====================
|
||||||
|
|
||||||
|
@@ -263,7 +263,7 @@ struct MemManager {
|
|||||||
if (next == firstUnaddressable) {
|
if (next == firstUnaddressable) {
|
||||||
mprotectSafe(base + firstUnaddressable, kUpsizeBytes,
|
mprotectSafe(base + firstUnaddressable, kUpsizeBytes,
|
||||||
PROT_READ | PROT_WRITE);
|
PROT_READ | PROT_WRITE);
|
||||||
VALGRIND_MAKE_MEM_UNDEFINED(base + firstUnaddressable, kUpsizeBytes);
|
VALGRIND_MAKE_MEM_NOACCESS(base + firstUnaddressable, kUpsizeBytes);
|
||||||
firstUnaddressable += kUpsizeNodes;
|
firstUnaddressable += kUpsizeNodes;
|
||||||
#if SHOW_MEMORY
|
#if SHOW_MEMORY
|
||||||
mmapBytes = getBytes();
|
mmapBytes = getBytes();
|
||||||
@@ -278,15 +278,18 @@ struct MemManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALGRIND_MAKE_MEM_UNDEFINED(base + next, sizeof(Node));
|
||||||
return next++;
|
return next++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gc(const uint32_t *roots, int numRoots, int64_t oldestVersion) {
|
void gc(const uint32_t *roots, int numRoots, int64_t oldestVersion) {
|
||||||
// Calculate reachable set
|
// Calculate reachable set
|
||||||
BitSet reachable{next};
|
BitSet reachable{next};
|
||||||
// Each node has at most 3 children and nodes along the search path aren't
|
Arena arena;
|
||||||
// in the stack, so we need 2 * kPathLengthUpperBound
|
constexpr int kInitialStackCapacity = 128;
|
||||||
uint32_t stack[2 * kPathLengthUpperBound];
|
int64_t stackCapacity = kInitialStackCapacity;
|
||||||
|
uint32_t stackStack[kInitialStackCapacity];
|
||||||
|
uint32_t *stack = stackStack;
|
||||||
int stackIndex = 0;
|
int stackIndex = 0;
|
||||||
auto tryPush = [&]([[maybe_unused]] uint32_t parent, uint32_t child) {
|
auto tryPush = [&]([[maybe_unused]] uint32_t parent, uint32_t child) {
|
||||||
if (!reachable.set(child)) {
|
if (!reachable.set(child)) {
|
||||||
@@ -295,7 +298,12 @@ struct MemManager {
|
|||||||
printf(" GC: reach: %u (parent %u)\n", child, parent);
|
printf(" GC: reach: %u (parent %u)\n", child, parent);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
assert(stackIndex < int(sizeof(stack) / sizeof(stack[0])));
|
if (stackIndex == stackCapacity) [[unlikely]] {
|
||||||
|
auto *old = stack;
|
||||||
|
stackCapacity *= 2;
|
||||||
|
stack = new (arena) uint32_t[stackCapacity];
|
||||||
|
memcpy(stack, old, stackIndex * sizeof(stack[0]));
|
||||||
|
}
|
||||||
stack[stackIndex++] = child;
|
stack[stackIndex++] = child;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -377,6 +385,9 @@ struct MemManager {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
next = max + 1;
|
next = max + 1;
|
||||||
|
assert(firstUnaddressable >= next);
|
||||||
|
VALGRIND_MAKE_MEM_NOACCESS(base + next,
|
||||||
|
(firstUnaddressable - next) * sizeof(Node));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getBytes() const {
|
int64_t getBytes() const {
|
||||||
@@ -954,7 +965,10 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
|||||||
if (engulfLeft && engulfRight) {
|
if (engulfLeft && engulfRight) {
|
||||||
insert({next->getKey(), next->keyLen}, {}, /*endRange*/ true, copy);
|
insert({next->getKey(), next->keyLen}, {}, /*endRange*/ true, copy);
|
||||||
if (found) {
|
if (found) {
|
||||||
remove(iter);
|
move<std::memory_order_relaxed, false>(copy, latestVersion);
|
||||||
|
// Point to the same entry as iter pointed to, but it's not
|
||||||
|
// invalidated
|
||||||
|
remove(copy);
|
||||||
}
|
}
|
||||||
} else if (engulfLeft) {
|
} else if (engulfLeft) {
|
||||||
assert(found);
|
assert(found);
|
||||||
@@ -963,6 +977,10 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
|||||||
/*endRange*/ true, iter);
|
/*endRange*/ true, iter);
|
||||||
} else if (engulfRight) {
|
} else if (engulfRight) {
|
||||||
insert({m.param1, m.param1Len}, {}, /*endRange*/ false, iter);
|
insert({m.param1, m.param1Len}, {}, /*endRange*/ false, iter);
|
||||||
|
move<std::memory_order_relaxed, true>(iter, latestVersion);
|
||||||
|
assert(iter.searchPathSize() > 0 &&
|
||||||
|
mm.base[iter.backNode()].entry == next);
|
||||||
|
insert({next->getKey(), next->keyLen}, {}, /*endRange*/ true, iter);
|
||||||
} else {
|
} else {
|
||||||
insert({m.param1, m.param1Len}, {{nullptr, -1}}, /*endRange*/ false,
|
insert({m.param1, m.param1Len}, {{nullptr, -1}}, /*endRange*/ false,
|
||||||
iter);
|
iter);
|
||||||
@@ -1200,8 +1218,11 @@ VersionedMap::Iterator::operator*() const {
|
|||||||
return impl->mutations[impl->mutationIndex];
|
return impl->mutations[impl->mutationIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
void materializeMutations(VersionedMap::Iterator::Impl *impl,
|
||||||
const Entry *next) {
|
const Entry *prev) {
|
||||||
|
const auto &entry = *impl->map->mm.base[impl->finger.backNode()].entry;
|
||||||
|
impl->mutationCount = 0;
|
||||||
|
if (entry.clearTo()) {
|
||||||
if (prev == nullptr) {
|
if (prev == nullptr) {
|
||||||
Finger copy;
|
Finger copy;
|
||||||
impl->finger.copyTo(copy);
|
impl->finger.copyTo(copy);
|
||||||
@@ -1212,18 +1233,7 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
|||||||
assert(!impl->map->mm.base[impl->finger.backNode()].entry->clearTo());
|
assert(!impl->map->mm.base[impl->finger.backNode()].entry->clearTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (next == nullptr) {
|
|
||||||
Finger copy;
|
|
||||||
impl->finger.copyTo(copy);
|
|
||||||
impl->map->move<std::memory_order_acquire, true>(copy, impl->version);
|
|
||||||
if (copy.searchPathSize() > 0) {
|
|
||||||
next = impl->map->mm.base[copy.backNode()].entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &entry = *impl->map->mm.base[impl->finger.backNode()].entry;
|
|
||||||
impl->mutationCount = 0;
|
|
||||||
if (entry.clearTo()) {
|
|
||||||
impl->mutations[impl->mutationCount++] = {
|
impl->mutations[impl->mutationCount++] = {
|
||||||
prev->getKey(),
|
prev->getKey(),
|
||||||
entry.getKey(),
|
entry.getKey(),
|
||||||
@@ -1234,7 +1244,6 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
|||||||
}
|
}
|
||||||
if (entry.pointMutation()) {
|
if (entry.pointMutation()) {
|
||||||
if (entry.valLen < 0 /* pointClear */) {
|
if (entry.valLen < 0 /* pointClear */) {
|
||||||
assert(next == nullptr || !next->clearTo());
|
|
||||||
impl->mutations[impl->mutationCount++] = {
|
impl->mutations[impl->mutationCount++] = {
|
||||||
entry.getKey(), nullptr, entry.keyLen, 0,
|
entry.getKey(), nullptr, entry.keyLen, 0,
|
||||||
VersionedMap::Clear, entry.pointVersion};
|
VersionedMap::Clear, entry.pointVersion};
|
||||||
@@ -1260,7 +1269,7 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator++() {
|
|||||||
if (impl->finger.searchPathSize() == 0) {
|
if (impl->finger.searchPathSize() == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
materializeMutations(impl, &entry, nullptr);
|
materializeMutations(impl, &entry);
|
||||||
} while (impl->mutationCount == 0);
|
} while (impl->mutationCount == 0);
|
||||||
impl->mutationIndex = 0;
|
impl->mutationIndex = 0;
|
||||||
|
|
||||||
@@ -1294,13 +1303,11 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator--() {
|
|||||||
impl->finger.push(c, true);
|
impl->finger.push(c, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Entry *next = nullptr;
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
materializeMutations(impl, nullptr, next);
|
materializeMutations(impl, nullptr);
|
||||||
if (impl->mutationCount > 0) {
|
if (impl->mutationCount > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
next = impl->map->mm.base[impl->finger.backNode()].entry;
|
|
||||||
impl->map->move<std::memory_order_acquire, false>(impl->finger,
|
impl->map->move<std::memory_order_acquire, false>(impl->finger,
|
||||||
impl->version);
|
impl->version);
|
||||||
}
|
}
|
||||||
@@ -1309,13 +1316,12 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator--() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const Entry *entry = impl->map->mm.base[impl->finger.backNode()].entry;
|
|
||||||
impl->map->move<std::memory_order_acquire, false>(impl->finger,
|
impl->map->move<std::memory_order_acquire, false>(impl->finger,
|
||||||
impl->version);
|
impl->version);
|
||||||
if (impl->finger.searchPathSize() == 0) {
|
if (impl->finger.searchPathSize() == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
materializeMutations(impl, nullptr, entry);
|
materializeMutations(impl, nullptr);
|
||||||
} while (impl->mutationCount == 0);
|
} while (impl->mutationCount == 0);
|
||||||
impl->mutationIndex = impl->mutationCount - 1;
|
impl->mutationIndex = impl->mutationCount - 1;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -1390,7 +1396,7 @@ void VersionedMap::Impl::StepwiseFirstGeq::end() {
|
|||||||
if (finger.searchPathSize() == 0) {
|
if (finger.searchPathSize() == 0) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
materializeMutations(iterator->impl, prev, nullptr);
|
materializeMutations(iterator->impl, prev);
|
||||||
for (int j = 0; j < iterator->impl->mutationCount; ++j) {
|
for (int j = 0; j < iterator->impl->mutationCount; ++j) {
|
||||||
if (geq(iterator->impl->mutations[j], *key)) {
|
if (geq(iterator->impl->mutations[j], *key)) {
|
||||||
iterator->impl->mutationIndex = j;
|
iterator->impl->mutationIndex = j;
|
||||||
@@ -1542,7 +1548,7 @@ VersionedMap::Iterator VersionedMap::begin(int64_t version) const {
|
|||||||
const Entry *prev = nullptr;
|
const Entry *prev = nullptr;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (result.impl->finger.searchPathSize() > 0) {
|
if (result.impl->finger.searchPathSize() > 0) {
|
||||||
materializeMutations(result.impl, prev, nullptr);
|
materializeMutations(result.impl, prev);
|
||||||
if (result.impl->mutationCount > 0) {
|
if (result.impl->mutationCount > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@@ -1,2 +0,0 @@
|
|||||||
~0<><30>
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> zzzz zzz zz<7A><7A><EFBFBD><EFBFBD><EFBFBD>zz zzNz zzzz zzz zzz S<><53><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD>5[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>젠<EFBFBD><ECA0A0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/049b93d0b37897eee0821c5076dba60da11ac14e
Normal file
BIN
corpus/049b93d0b37897eee0821c5076dba60da11ac14e
Normal file
Binary file not shown.
BIN
corpus/050ba22241a7c4f6453f46acf1e7d4db8d1d0425
Normal file
BIN
corpus/050ba22241a7c4f6453f46acf1e7d4db8d1d0425
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/060258d36ad61f7fb8c80220e0d2041cdf1aa808
Normal file
BIN
corpus/060258d36ad61f7fb8c80220e0d2041cdf1aa808
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/0626c4d77e138b08ad951c6ba8205edb21b15bd4
Normal file
BIN
corpus/0626c4d77e138b08ad951c6ba8205edb21b15bd4
Normal file
Binary file not shown.
BIN
corpus/066d600c04c7f35e67b59e7ed4a5e6084db019eb
Normal file
BIN
corpus/066d600c04c7f35e67b59e7ed4a5e6084db019eb
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/081fe921b591c394f8200353e15bd9518dd30873
Normal file
BIN
corpus/081fe921b591c394f8200353e15bd9518dd30873
Normal file
Binary file not shown.
BIN
corpus/08a0b2e8caa2c0bce06e0ede272a7cf986ce72b0
Normal file
BIN
corpus/08a0b2e8caa2c0bce06e0ede272a7cf986ce72b0
Normal file
Binary file not shown.
BIN
corpus/08c0ffb93b5787c8b72e2f33301c263ff565eff9
Normal file
BIN
corpus/08c0ffb93b5787c8b72e2f33301c263ff565eff9
Normal file
Binary file not shown.
Binary file not shown.
1
corpus/0b8a75495f28f63035902ed881281a2c24b18591
Normal file
1
corpus/0b8a75495f28f63035902ed881281a2c24b18591
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<EFBFBD><EFBFBD><EFBFBD>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
corpus/11ea9a244916ded6f8c590be6f669e62a25585ef
Normal file
1
corpus/11ea9a244916ded6f8c590be6f669e62a25585ef
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Z<0B>G
|
BIN
corpus/12fdcc5a6e96bcbf86da08a8e63bb03f3009a44b
Normal file
BIN
corpus/12fdcc5a6e96bcbf86da08a8e63bb03f3009a44b
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/1a20625f70035e308a3fe79e34f994e145eaddac
Normal file
BIN
corpus/1a20625f70035e308a3fe79e34f994e145eaddac
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/1e5a8eea0617c70f7f06a55affb08c78e4037dc6
Normal file
BIN
corpus/1e5a8eea0617c70f7f06a55affb08c78e4037dc6
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/1f9aed570e2c5ba3bd23e0d38d79dd8fc8a0a37f
Normal file
BIN
corpus/1f9aed570e2c5ba3bd23e0d38d79dd8fc8a0a37f
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/22ce91f0bcf3df112614c91c66eef5c7b480e32d
Normal file
BIN
corpus/22ce91f0bcf3df112614c91c66eef5c7b480e32d
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/2546561601ce0a99fb3516a5cdd3c0b370d8953c
Normal file
BIN
corpus/2546561601ce0a99fb3516a5cdd3c0b370d8953c
Normal file
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
'*9
|
|
BIN
corpus/25a5e8480699a8f91c6cfbe1f127fb724c653257
Normal file
BIN
corpus/25a5e8480699a8f91c6cfbe1f127fb724c653257
Normal file
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
k<04><><EFBFBD><0B><><EFBFBD><EFBFBD><EFBFBD><0B>'<27>'*<2A>
|
|
Binary file not shown.
Binary file not shown.
BIN
corpus/29157d94f7c83590715be8ffa7d8b32670e8980e
Normal file
BIN
corpus/29157d94f7c83590715be8ffa7d8b32670e8980e
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/2c03c9ae5bff63dc89f871bc5efd98872e0eec47
Normal file
BIN
corpus/2c03c9ae5bff63dc89f871bc5efd98872e0eec47
Normal file
Binary file not shown.
BIN
corpus/2fea6c2789f46e07c41708c2fc79d814de4b71c5
Normal file
BIN
corpus/2fea6c2789f46e07c41708c2fc79d814de4b71c5
Normal file
Binary file not shown.
BIN
corpus/3086de09c1ad983312329465ddf8a53316efed63
Normal file
BIN
corpus/3086de09c1ad983312329465ddf8a53316efed63
Normal file
Binary file not shown.
BIN
corpus/3399390c54906545d5b0b5712f7f1d01b610dc3c
Normal file
BIN
corpus/3399390c54906545d5b0b5712f7f1d01b610dc3c
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/3492820f4904b3dec4658d140664742f3722356d
Normal file
BIN
corpus/3492820f4904b3dec4658d140664742f3722356d
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/36ae369d433ca73dbc85d41793d9af592030de3e
Normal file
BIN
corpus/36ae369d433ca73dbc85d41793d9af592030de3e
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/396f62cfb1a01d5d421a340b0dc083589da7f4cb
Normal file
BIN
corpus/396f62cfb1a01d5d421a340b0dc083589da7f4cb
Normal file
Binary file not shown.
BIN
corpus/3bc7c3dfaba11e297d27a04c1771c1c481e048b2
Normal file
BIN
corpus/3bc7c3dfaba11e297d27a04c1771c1c481e048b2
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/3ddeb49a7dd892c5731d4f276d30bb7336341c22
Normal file
BIN
corpus/3ddeb49a7dd892c5731d4f276d30bb7336341c22
Normal file
Binary file not shown.
BIN
corpus/3ecae1ba3f50fec92414e0eaed6d75134160c533
Normal file
BIN
corpus/3ecae1ba3f50fec92414e0eaed6d75134160c533
Normal file
Binary file not shown.
BIN
corpus/3ed85e2e2a9f6ed6fb41fffd148f90c99897b1c8
Normal file
BIN
corpus/3ed85e2e2a9f6ed6fb41fffd148f90c99897b1c8
Normal file
Binary file not shown.
BIN
corpus/4058fa88405a8a07debbd011aa40ef45a4c3b36f
Normal file
BIN
corpus/4058fa88405a8a07debbd011aa40ef45a4c3b36f
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/41a431da68882fee11254f4cbbd2ed2a24b4e02c
Normal file
BIN
corpus/41a431da68882fee11254f4cbbd2ed2a24b4e02c
Normal file
Binary file not shown.
BIN
corpus/425c92dd20a6f59cdda4ff65f8e133a22e033b36
Normal file
BIN
corpus/425c92dd20a6f59cdda4ff65f8e133a22e033b36
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/42b5755aa9b8dcb87d15106af7d251564e409da9
Normal file
BIN
corpus/42b5755aa9b8dcb87d15106af7d251564e409da9
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/43bb117b2547cbaaee95c8ca51f527e6dca74eb5
Normal file
BIN
corpus/43bb117b2547cbaaee95c8ca51f527e6dca74eb5
Normal file
Binary file not shown.
Binary file not shown.
BIN
corpus/43c8ad67df655ff95b85c1824f5e615d33a9725f
Normal file
BIN
corpus/43c8ad67df655ff95b85c1824f5e615d33a9725f
Normal file
Binary file not shown.
BIN
corpus/447e6c228d4dc3bdbf00d2effecfa59f7e257404
Normal file
BIN
corpus/447e6c228d4dc3bdbf00d2effecfa59f7e257404
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
corpus/4615b6ada95efe65b47ca64e5c83306a5690418e
Normal file
BIN
corpus/4615b6ada95efe65b47ca64e5c83306a5690418e
Normal file
Binary file not shown.
BIN
corpus/4640301fd97f80a8a6915a244ec2716bfbe796f9
Normal file
BIN
corpus/4640301fd97f80a8a6915a244ec2716bfbe796f9
Normal file
Binary file not shown.
BIN
corpus/46987f1d8ae9ba859d8e5ded3e1309dcde3abadc
Normal file
BIN
corpus/46987f1d8ae9ba859d8e5ded3e1309dcde3abadc
Normal file
Binary file not shown.
BIN
corpus/47d5969fe77ca4e23c8de2a424cbc0b486080c97
Normal file
BIN
corpus/47d5969fe77ca4e23c8de2a424cbc0b486080c97
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user