Use a different allocator for per-pull allocations

Reviewers: mtomic, mferencevic

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2137
This commit is contained in:
Teon Banek 2019-06-17 13:58:54 +02:00
parent 5adb4aafe0
commit e9dcb1dcf2

View File

@ -95,6 +95,8 @@ class Interpreter {
plan_(plan),
execution_memory_(std::make_unique<utils::MonotonicBufferResource>(
kExecutionMemoryBlockSize)),
per_pull_memory_(std::make_unique<utils::MonotonicBufferResource>(
kExecutionMemoryBlockSize)),
cursor_(
plan_->plan().MakeCursor(db_accessor, execution_memory_.get())),
frame_(plan_->symbol_table().max_position(), execution_memory_.get()),
@ -105,8 +107,7 @@ class Interpreter {
should_abort_query_(should_abort_query) {
ctx_.is_profile_query = is_profile_query;
ctx_.symbol_table = plan_->symbol_table();
// TODO: Maybe we want a seperate MemoryResource per pull evaluation
ctx_.evaluation_context.memory = execution_memory_.get();
ctx_.evaluation_context.memory = per_pull_memory_.get();
ctx_.evaluation_context.timestamp =
std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
@ -137,6 +138,7 @@ class Interpreter {
template <typename TStream>
bool Pull(TStream &stream) {
utils::Timer timer;
per_pull_memory_->Release();
bool return_value = cursor_->Pull(frame_, ctx_);
if (return_value && !output_symbols_.empty()) {
std::vector<TypedValue> values;
@ -181,9 +183,11 @@ class Interpreter {
private:
ExecutionContext ctx_;
std::shared_ptr<CachedPlan> plan_;
// execution_memory_ is unique_ptr because we are passing the address to
// cursor_, and we want to preserve the pointer in case we get moved.
// execution_memory_ and per_pull_memory_ are unique_ptr, because we are
// passing the address to cursor_, and we want to preserve the pointer in
// case we get moved.
std::unique_ptr<utils::MonotonicBufferResource> execution_memory_;
std::unique_ptr<utils::MonotonicBufferResource> per_pull_memory_;
query::plan::UniqueCursorPtr cursor_;
Frame frame_;
std::vector<Symbol> output_symbols_;