memgraph/tests/benchmark/mvcc.cpp

71 lines
1.7 KiB
C++
Raw Normal View History

#include <benchmark/benchmark.h>
#include <benchmark/benchmark_api.h>
#include <glog/logging.h>
#include "mvcc/record.hpp"
#include "mvcc/version_list.hpp"
#include "transactions/engine_single_node.hpp"
class Prop : public mvcc::Record<Prop> {
public:
Prop() = default;
Prop *CloneData() { return new Prop; }
};
// Benchmark multiple updates, and finds, focused on finds.
// This a rather weak test, but I'm not sure what's the better way to test this
// in the future.
// TODO(dgleich): Refresh this.
void MvccMix(benchmark::State &state) {
while (state.KeepRunning()) {
state.PauseTiming();
tx::SingleNodeEngine engine;
auto t1 = engine.Begin();
Write-ahead log Summary: My dear fellow Memgraphians. It's friday afternoon, and I am as ready to pop as WAL is to get reviewed... What's done: - Vertices and Edges have global IDs, stored in `VersionList`. Main storage is now a concurrent map ID->vlist_ptr. - WriteAheadLog class added. It's based around buffering WAL::Op objects (elementraly DB changes) and periodically serializing and flusing them to disk. - Snapshot recovery refactored, WAL recovery added. Snapshot format changed again to include necessary info. - Durability testing completely reworked. What's not done (and should be when we decide how): - Old WAL file purging. - Config refactor (naming and organization). Will do when we discuss what we want. - Changelog and new feature documentation (both depending on the point above). - Better error handling and recovery feedback. Currently it's all returning bools, which is not fine-grained enough (neither for errors nor partial successes, also EOF is reported as a failure at the moment). - Moving the implementation of WAL stuff to .cpp where possible. - Not sure if there are transactions being created outside of `GraphDbAccessor` and it's `BuildIndex`. Need to look into. - True write-ahead logic (flag controlled): not committing a DB transaction if the WAL has not flushed it's data. We can discuss the gain/effort ratio for this feature. Reviewers: buda, mislav.bradac, teon.banek, dgleich Reviewed By: dgleich Subscribers: mtomic, pullbot Differential Revision: https://phabricator.memgraph.io/D958
2017-11-13 16:50:49 +08:00
mvcc::VersionList<Prop> version_list(*t1, 0);
engine.Commit(*t1);
auto t2 = engine.Begin();
state.ResumeTiming();
version_list.update(*t2);
state.PauseTiming();
state.ResumeTiming();
version_list.find(*t2);
state.PauseTiming();
engine.Abort(*t2);
auto t3 = engine.Begin();
state.ResumeTiming();
version_list.update(*t3);
state.PauseTiming();
auto t4 = engine.Begin();
// Repeat find state.range(0) number of times.
state.ResumeTiming();
for (int i = 0; i < state.range(0); ++i) {
version_list.find(*t4);
}
state.PauseTiming();
engine.Commit(*t3);
engine.Commit(*t4);
state.ResumeTiming();
}
}
BENCHMARK(MvccMix)
->RangeMultiplier(2) // Multiply next range testdata size by 2
->Range(1 << 14, 1 << 23) // 1<<14, 1<<15, 1<<16, ...
->Unit(benchmark::kMillisecond);
DEFINE_string(hehehe, "bok", "ne");
int main(int argc, char **argv) {
google::InitGoogleLogging(argv[0]);
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
return 0;
}