Merge pull request #1393 from jzhou77/pprof

Gperftools Profiling fix.
This commit is contained in:
Jingyu Zhou 2019-04-03 10:35:31 -07:00 committed by GitHub
commit fc59587b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 3 deletions

View File

@ -6,6 +6,10 @@ set(ALLOC_INSTRUMENTATION OFF CACHE BOOL "Instrument alloc")
set(WITH_UNDODB OFF CACHE BOOL "Use rr or undodb")
set(FDB_RELEASE OFF CACHE BOOL "This is a building of a final release")
if(USE_GPERFTOOLS)
find_package(Gperftools REQUIRED)
endif()
add_compile_options(-DCMAKE_BUILD)
add_compile_definitions(BOOST_ERROR_CODE_HEADER_ONLY BOOST_SYSTEM_NO_DEPRECATED)
@ -122,6 +126,13 @@ else()
-Wreturn-type
-fdiagnostics-color=always
-fPIC)
if (GPERFTOOLS_FOUND AND GCC)
add_compile_options(
-fno-builtin-malloc
-fno-builtin-calloc
-fno-builtin-realloc
-fno-builtin-free)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(USE_LTO OFF CACHE BOOL "Do link time optimization")

View File

@ -49,3 +49,10 @@ mark_as_advanced(
GPERFTOOLS_TCMALLOC_AND_PROFILER
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)
if (GPERFTOOLS_FOUND)
add_library(gperftools UNKNOWN IMPORTED)
set_target_properties(gperftools PROPERTIES
IMPORTED_LOCATION ${GPERFTOOLS_TCMALLOC_AND_PROFILER}
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}")
endif()

View File

@ -31,3 +31,8 @@ if(NOT OPEN_FOR_IDE)
FILE_NAME fdbbackup
LINK_NAME fdbdr)
endif()
if (GPERFTOOLS_FOUND)
add_compile_definitions(USE_GPERFTOOLS)
target_link_libraries(fdbbackup PRIVATE gperftools)
endif()

View File

@ -29,7 +29,7 @@ ifeq ($(PLATFORM),linux)
fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
# GPerfTools profiler (uncomment to use)
# fdbbackup_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
# fdbbackup_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
# fdbbackup_LDFLAGS += -L/opt/gperftools/lib
# fdbbackup_STATIC_LIBS += -ltcmalloc -lunwind -lprofiler
else ifeq ($(PLATFORM),osx)

View File

@ -184,5 +184,9 @@ target_include_directories(fdbserver PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/workloads
${CMAKE_CURRENT_SOURCE_DIR}/workloads)
target_link_libraries(fdbserver PRIVATE fdbclient)
if (GPERFTOOLS_FOUND)
add_compile_definitions(USE_GPERFTOOLS)
target_link_libraries(fdbserver PRIVATE gperftools)
endif()
fdb_install(TARGETS fdbserver DESTINATION sbin COMPONENT server)

View File

@ -29,7 +29,7 @@ ifeq ($(PLATFORM),linux)
fdbserver_LDFLAGS += -ldl -lpthread -lrt -static-libstdc++ -static-libgcc
# GPerfTools profiler (uncomment to use)
# fdbserver_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
# fdbserver_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
# fdbserver_LDFLAGS += -L/opt/gperftools/lib
# fdbserver_STATIC_LIBS += -ltcmalloc -lunwind -lprofiler
else ifeq ($(PLATFORM),osx)

View File

@ -407,7 +407,6 @@ void updateCpuProfiler(ProfilerRequest req) {
options->filter_in_thread = &filter_in_thread;
options->filter_in_thread_arg = NULL;
ProfilerStartWithOptions(path, options);
free(workingDir);
break;
}
case ProfilerRequest::Action::DISABLE: