Use custom allocator in Evaluator through context

Summary:
Micro benchmarks show improvements in performance of MapLiteral from 5%
to 40% depending on the size of the input. On the other hand, a sequence
of AdditionOperators behaves the same with both allocation schemes.

Reviewers: mtomic, mferencevic, msantl

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2132
This commit is contained in:
Teon Banek
2019-06-07 14:31:25 +02:00
parent 57d967786c
commit 3fd14e2d5f
8 changed files with 200 additions and 68 deletions

View File

@@ -33,12 +33,12 @@ class ExpressionEvaluatorTest : public ::testing::Test {
database::GraphDbAccessor dba{db.Access()};
AstStorage storage;
EvaluationContext ctx;
utils::MonotonicBufferResource mem{1024};
EvaluationContext ctx{&mem};
SymbolTable symbol_table;
Frame frame{128};
ExpressionEvaluator eval{&frame, symbol_table, ctx, &dba,
GraphView::OLD};
ExpressionEvaluator eval{&frame, symbol_table, ctx, &dba, GraphView::OLD};
Identifier *CreateIdentifierWithValue(std::string name,
const TypedValue &value) {
@@ -53,7 +53,11 @@ class ExpressionEvaluatorTest : public ::testing::Test {
auto Eval(TExpression *expr) {
ctx.properties = NamesToProperties(storage.properties_, &dba);
ctx.labels = NamesToLabels(storage.labels_, &dba);
return expr->Accept(eval);
auto value = expr->Accept(eval);
EXPECT_EQ(value.GetMemoryResource(), &mem)
<< "ExpressionEvaluator must use the MemoryResource from "
"EvaluationContext for allocations!";
return value;
}
};