Add insert benchmark
This commit is contained in:
parent
c5138c8d58
commit
243fa5e4b2
@ -26,11 +26,12 @@ using PrimaryKey = std::vector<PropertyValue>;
|
||||
|
||||
class KeyStore {
|
||||
public:
|
||||
KeyStore() = default;
|
||||
explicit KeyStore(const PrimaryKey &key_values);
|
||||
|
||||
KeyStore(const KeyStore &) = delete;
|
||||
KeyStore(const KeyStore &) = default;
|
||||
KeyStore(KeyStore &&other) noexcept = default;
|
||||
KeyStore &operator=(const KeyStore &) = delete;
|
||||
KeyStore &operator=(const KeyStore &) = default;
|
||||
KeyStore &operator=(KeyStore &&other) noexcept = default;
|
||||
|
||||
~KeyStore() = default;
|
||||
|
@ -928,6 +928,16 @@ void SetSizeData(uint8_t *buffer, uint64_t size, uint8_t *data) {
|
||||
|
||||
PropertyStore::PropertyStore() { memset(buffer_, 0, sizeof(buffer_)); }
|
||||
|
||||
PropertyStore::PropertyStore(const PropertyStore &other) { memcpy(buffer_, other.buffer_, sizeof(buffer_)); }
|
||||
|
||||
PropertyStore &PropertyStore::operator=(const PropertyStore &other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
memcpy(buffer_, other.buffer_, sizeof(buffer_));
|
||||
return *this;
|
||||
}
|
||||
|
||||
PropertyStore::PropertyStore(PropertyStore &&other) noexcept {
|
||||
memcpy(buffer_, other.buffer_, sizeof(buffer_));
|
||||
memset(other.buffer_, 0, sizeof(other.buffer_));
|
||||
|
@ -25,9 +25,9 @@ class PropertyStore {
|
||||
public:
|
||||
PropertyStore();
|
||||
|
||||
PropertyStore(const PropertyStore &) = delete;
|
||||
PropertyStore(const PropertyStore &);
|
||||
PropertyStore(PropertyStore &&other) noexcept;
|
||||
PropertyStore &operator=(const PropertyStore &) = delete;
|
||||
PropertyStore &operator=(const PropertyStore &);
|
||||
PropertyStore &operator=(PropertyStore &&other) noexcept;
|
||||
|
||||
~PropertyStore();
|
||||
|
@ -31,6 +31,8 @@ namespace memgraph::storage::v3 {
|
||||
struct Vertex {
|
||||
using EdgeLink = std::tuple<EdgeTypeId, VertexId, EdgeRef>;
|
||||
|
||||
Vertex() = default;
|
||||
|
||||
Vertex(Delta *delta, const std::vector<PropertyValue> &primary_properties) : keys{primary_properties}, delta{delta} {
|
||||
MG_ASSERT(delta == nullptr || delta->action == Delta::Action::DELETE_OBJECT,
|
||||
"Vertex must be created with an initial DELETE_OBJECT delta!");
|
||||
|
@ -68,5 +68,14 @@ target_link_libraries(${test_prefix}storage_v2_property_store mg-storage-v2)
|
||||
add_benchmark(future.cpp)
|
||||
target_link_libraries(${test_prefix}future mg-io)
|
||||
|
||||
add_benchmark(data_structures.cpp)
|
||||
target_link_libraries(${test_prefix}data_structures mg-utils)
|
||||
add_benchmark(data_structures_random.cpp)
|
||||
target_link_libraries(${test_prefix}data_structures_random mg-utils)
|
||||
|
||||
add_benchmark(data_structures_insert.cpp)
|
||||
target_link_libraries(${test_prefix}data_structures_insert mg-utils mg-storage-v3)
|
||||
|
||||
add_benchmark(data_structures_find.cpp)
|
||||
target_link_libraries(${test_prefix}data_structures_find mg-utils mg-storage-v3)
|
||||
|
||||
add_benchmark(data_structures_contains.cpp)
|
||||
target_link_libraries(${test_prefix}data_structures_contains mg-utils mg-storage-v3)
|
||||
|
113
tests/benchmark/data_structures_insert.cpp
Normal file
113
tests/benchmark/data_structures_insert.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <atomic>
|
||||
#include <concepts>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "btree_map.hpp"
|
||||
#include "skip_list_common.hpp"
|
||||
#include "storage/v3/key_store.hpp"
|
||||
#include "storage/v3/lexicographically_ordered_vertex.hpp"
|
||||
#include "storage/v3/mvcc.hpp"
|
||||
#include "storage/v3/property_value.hpp"
|
||||
#include "storage/v3/transaction.hpp"
|
||||
#include "storage/v3/vertex.hpp"
|
||||
#include "utils/skip_list.hpp"
|
||||
|
||||
namespace memgraph::benchmark {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Testing Insert Operation
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static void BM_BenchmarkInsertSkipList(::benchmark::State &state) {
|
||||
utils::SkipList<storage::v3::LexicographicallyOrderedVertex> skip_list;
|
||||
coordinator::Hlc start_timestamp;
|
||||
storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION};
|
||||
storage::v3::Transaction transaction{start_timestamp, isolation_level};
|
||||
auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction);
|
||||
|
||||
for (auto _ : state) {
|
||||
for (auto i{0}; i < state.range(0); ++i) {
|
||||
auto acc = skip_list.access();
|
||||
acc.insert({storage::v3::Vertex(delta, std::vector<storage::v3::PropertyValue>{storage::v3::PropertyValue{i}})});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_BenchmarkInsertStdMap(::benchmark::State &state) {
|
||||
std::map<storage::v3::PrimaryKey, storage::v3::LexicographicallyOrderedVertex> std_map;
|
||||
coordinator::Hlc start_timestamp;
|
||||
storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION};
|
||||
storage::v3::Transaction transaction{start_timestamp, isolation_level};
|
||||
auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction);
|
||||
|
||||
for (auto _ : state) {
|
||||
for (auto i{0}; i < state.range(0); ++i) {
|
||||
std_map.insert({storage::v3::PrimaryKey{storage::v3::PropertyValue{i}},
|
||||
storage::v3::LexicographicallyOrderedVertex{storage::v3::Vertex{
|
||||
delta, std::vector<storage::v3::PropertyValue>{storage::v3::PropertyValue{i}}}}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_BenchmarkInsertStdSet(::benchmark::State &state) {
|
||||
std::set<storage::v3::LexicographicallyOrderedVertex> std_set;
|
||||
coordinator::Hlc start_timestamp;
|
||||
storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION};
|
||||
storage::v3::Transaction transaction{start_timestamp, isolation_level};
|
||||
auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction);
|
||||
|
||||
for (auto _ : state) {
|
||||
for (auto i{0}; i < state.range(0); ++i) {
|
||||
std_set.insert(storage::v3::LexicographicallyOrderedVertex{
|
||||
storage::v3::Vertex{delta, std::vector<storage::v3::PropertyValue>{storage::v3::PropertyValue{i}}}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_BenchmarkInsertBppTree(::benchmark::State &state) {
|
||||
tlx::btree_map<storage::v3::PrimaryKey, storage::v3::LexicographicallyOrderedVertex> bpp_tree;
|
||||
coordinator::Hlc start_timestamp;
|
||||
storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION};
|
||||
storage::v3::Transaction transaction{start_timestamp, isolation_level};
|
||||
auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction);
|
||||
|
||||
for (auto _ : state) {
|
||||
for (auto i{0}; i < state.range(0); ++i) {
|
||||
bpp_tree.insert({storage::v3::PrimaryKey{storage::v3::PropertyValue{i}},
|
||||
storage::v3::LexicographicallyOrderedVertex{storage::v3::Vertex{
|
||||
delta, std::vector<storage::v3::PropertyValue>{storage::v3::PropertyValue{i}}}}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(BM_BenchmarkInsertSkipList)->Arg(1000);
|
||||
|
||||
BENCHMARK(BM_BenchmarkInsertStdMap)->Arg(1000);
|
||||
|
||||
BENCHMARK(BM_BenchmarkInsertStdSet)->Arg(1000);
|
||||
|
||||
BENCHMARK(BM_BenchmarkInsertBppTree)->Arg(1000);
|
||||
|
||||
} // namespace memgraph::benchmark
|
||||
|
||||
BENCHMARK_MAIN();
|
Loading…
Reference in New Issue
Block a user