Skip unversioned until non-adjacent mutation in facade

Only implemented for forward reads so far
This commit is contained in:
2024-06-17 11:57:11 -07:00
parent b2ce851d56
commit fcb881f408
2 changed files with 99 additions and 12 deletions

View File

@@ -103,7 +103,62 @@ void bulkFirstGeq() {
[&] { versionedMap.firstGeq(keys, iterators, kNumQueries); });
}
void facadeVersionedOnlyRead() {
Facade facade{0};
constexpr int kNumKeys = 10000;
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);
}
// Add keys
for (int i = 0; i < kNumKeys; ++i) {
const int64_t k = __builtin_bswap64(i);
weaselab::VersionedMap::Mutation mutations[] = {
{(const uint8_t *)&k, 8, (const uint8_t *)&k, 8,
weaselab::VersionedMap::Set},
};
facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]),
facade.getVersion() + 1);
}
// Populate the unversioned map
for (int i = 0; i < kNumKeys; ++i) {
const int64_t k = __builtin_bswap64(i);
weaselab::VersionedMap::Mutation mutations[] = {
{(const uint8_t *)&k, 8, (const uint8_t *)&k, 8,
weaselab::VersionedMap::Set},
};
facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]),
facade.getVersion() + 1);
}
facade.setOldestVersion(facade.getVersion() - 1, /*force*/ true);
bench.run("Facade versioned-only read forward", [&]() {
facade.viewAt(facade.getVersion()).rangeRead(begin, end, kNumKeys, false);
});
bench.run("Facade versioned-only read reverse", [&]() {
facade.viewAt(facade.getVersion()).rangeRead(begin, end, kNumKeys, true);
});
}
int main() {
monotonicallyIncreasing();
bulkFirstGeq();
facadeVersionedOnlyRead();
}