Compare commits

...

2 Commits

Author SHA1 Message Date
Andi Skrgat
cb41396e86 Local shared poc 2023-05-08 15:55:52 +02:00
Aidar Samerkhanov
614e321ebb Get rid of unnecessary copy during query engine iterator operator++ 2023-05-08 10:56:03 +00:00
2 changed files with 20 additions and 14 deletions

View File

@@ -14,6 +14,7 @@
#include <optional>
#include <type_traits>
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <cppitertools/filter.hpp>
#include <cppitertools/imap.hpp>
@@ -21,6 +22,7 @@
#include "storage/v2/id_types.hpp"
#include "storage/v2/property_value.hpp"
#include "storage/v2/result.hpp"
#include "storage/v2/vertex_accessor.hpp"
#include "utils/pmr/unordered_set.hpp"
#include "utils/variant_helpers.hpp"
@@ -120,19 +122,28 @@ class VertexAccessor final {
public:
// It can affect performance if we use std::unique_ptr here.
std::unique_ptr<storage::VertexAccessor> impl_;
// std::unique_ptr<storage::VertexAccessor> impl_;
// local_shared_ptr and all its local copies must reside in the same thread
boost::local_shared_ptr<storage::VertexAccessor> impl_;
// explicit VertexAccessor(std::unique_ptr<storage::VertexAccessor> impl) : impl_(std::move(impl)) {}
// increase reference count
explicit VertexAccessor(boost::local_shared_ptr<storage::VertexAccessor> impl) : impl_(impl) {}
// VertexAccessor(const VertexAccessor &impl) : impl_(impl.impl_->Copy()){};
VertexAccessor(const VertexAccessor &impl) : impl_(impl.impl_){};
explicit VertexAccessor(std::unique_ptr<storage::VertexAccessor> impl) : impl_(std::move(impl)) {}
VertexAccessor(const VertexAccessor &impl) : impl_(impl.impl_->Copy()){};
explicit VertexAccessor(VertexAccessor *impl) : VertexAccessor(*impl) {}
~VertexAccessor() = default;
VertexAccessor &operator=(const VertexAccessor &other) {
impl_ = other.impl_->Copy();
// impl_ = other.impl_->Copy();
// return *this;
impl_ = other.impl_;
return *this;
}
~VertexAccessor() = default;
bool IsVisible(storage::View view) const { return impl_->IsVisible(view); }
auto Labels(storage::View view) const { return impl_->Labels(view); }
@@ -301,7 +312,7 @@ class VerticesIterable final {
}
Iterator &operator++() {
std::visit([this](auto it_) { this->it_ = ++it_; }, it_);
std::visit([](auto &it_) { ++it_; }, it_);
return *this;
}

View File

@@ -29,7 +29,6 @@ QUERY_COUNT_LOWER_BOUND = 30
def parse_args():
parser = argparse.ArgumentParser(
description="Memgraph benchmark executor.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -205,7 +204,6 @@ def warmup(condition: str, client: runners.BaseRunner, queries: list = None):
def mixed_workload(
vendor: runners.BaseRunner, client: runners.BaseClient, dataset, group, queries, benchmark_context: BenchmarkContext
):
num_of_queries = benchmark_context.mode_config[0]
percentage_distribution = benchmark_context.mode_config[1:]
if sum(percentage_distribution) != 100:
@@ -233,7 +231,7 @@ def mixed_workload(
"analytical": [],
}
for (_, funcname) in queries[group]:
for _, funcname in queries[group]:
for key in queries_by_type.keys():
if key in funcname:
queries_by_type[key].append(funcname)
@@ -349,7 +347,6 @@ def get_query_cache_count(
config_key: list,
benchmark_context: BenchmarkContext,
):
cached_count = config.get_value(*config_key)
if cached_count is None:
log.info(
@@ -403,7 +400,6 @@ def get_query_cache_count(
if __name__ == "__main__":
args = parse_args()
vendor_specific_args = helpers.parse_kwargs(args.vendor_specific)
@@ -593,7 +589,7 @@ if __name__ == "__main__":
ret = client.execute(
queries=get_queries(func, count),
num_workers=benchmark_context.num_workers_for_benchmark,
time_dependent_execution=benchmark_context.time_depended_execution,
time_dependent_execution=benchmark_context.time_dependent_execution,
)[0]
else:
ret = client.execute(
@@ -647,7 +643,6 @@ if __name__ == "__main__":
vendor_runner.stop("authorization")
for query, funcname in queries[group]:
log.info(
"Running query:",
"{}/{}/{}/{}".format(group, query, funcname, WITH_FINE_GRAINED_AUTHORIZATION),