Change allocator.

Summary:
There seems to be a gain all over memgraph.
I strongly suggest including this in the codebase.

Link to project:
https://github.com/r-lyeh/ltalloc

Reviewers: teon.banek, mferencevic, mislav.bradac, florijan

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D914
This commit is contained in:
Dominik Gleich 2017-10-20 16:53:24 +02:00
parent b65fcc8f90
commit 184996d925
4 changed files with 25 additions and 9 deletions

View File

@ -52,6 +52,10 @@ add_custom_target(clean_all
# threading
find_package(Threads REQUIRED)
# optional Ltalloc
option(USE_LTALLOC "Use Ltalloc instead of default allocator (default ON). \
Set this to OFF to prevent linking with Ltalloc." ON)
# optional readline
option(USE_READLINE "Use GNU Readline library if available (default ON). \
Set this to OFF to prevent linking with Readline even if it is available." ON)
@ -69,6 +73,7 @@ endif()
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# For now, explicitly set -std= flag for C++17.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall")
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
@ -215,6 +220,13 @@ set(memgraph_src_files
# memgraph_lib depend on these libraries
set(MEMGRAPH_ALL_LIBS stdc++fs Threads::Threads fmt cppitertools
antlr_opencypher_parser_lib dl glog gflags)
if (USE_LTALLOC)
list(APPEND MEMGRAPH_ALL_LIBS ltalloc)
# TODO(mferencevic): Enable this when clang is updated on apollo.
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
endif()
if (READLINE_FOUND)
list(APPEND MEMGRAPH_ALL_LIBS readline)
endif()

View File

@ -94,6 +94,12 @@ import_external_library(fmt STATIC
# Skip testing.
CMAKE_ARGS -DFMT_TEST=OFF)
# Setup ltalloc library
add_library(ltalloc STATIC ltalloc/ltalloc.cc)
# TODO(mferencevic): Enable this when clang on apollo is updated
#target_compile_options(ltalloc PUBLIC -flto)
# setup rapidcheck (it cannot be external, since it doesn't have install
# target)
set(RC_ENABLE_GTEST ON CACHE BOOL "Build Google Test integration" FORCE)

View File

@ -107,3 +107,10 @@ cd json
#wget "https://raw.githubusercontent.com/nlohmann/json/91e003285312167ad8365f387438ea371b465a7e/src/json.hpp"
wget -nv http://deps.memgraph.io/json.hpp
cd ..
#ltalloc
git clone https://github.com/r-lyeh/ltalloc.git
ltalloc_tag="aefde2afa5cd49c9d1a797aa08ec08b2bec13a36" # Sep 15, 2017
cd ltalloc
git checkout ${ltalloc_tag}
cd ..

View File

@ -1,7 +1,5 @@
#include <functional>
#include <malloc.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
@ -136,13 +134,6 @@ void GraphDb::CollectGarbage() {
<< x.Elapsed().count();
}
{
utils::Timer x;
malloc_trim(0);
VLOG(1) << "Garbage collector malloc trim phase time: "
<< x.Elapsed().count();
}
LOG(INFO) << "Garbage collector finished";
VLOG(2) << "gc snapshot: " << snapshot;
VLOG(2) << "edge_record_deleter_ size: " << edge_record_deleter_.Count();