Skip to content

Commit

Permalink
Merge branch 'master' into 'master' (merge request !278)
Browse files Browse the repository at this point in the history
support jemalloc profile
support jemalloc profile
  • Loading branch information
TendisDev committed Feb 24, 2021
2 parents ae058cb + c00b64a commit 1af8b76
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
option(WITH_JEMALLOC "enable jemalloc of rocksdb" ON)

add_custom_command(OUTPUT "${JEMALLOC_ROOT_DIR}/include/jemalloc/jemalloc.h"
COMMAND ./autogen.sh
# NOTE(takenliu) support jemalloc profile, before start tendisplus need export as below:
# export MALLOC_CONF="prof:true,prof_prefix:jeprof.out"
COMMAND ./autogen.sh --enable-prof
WORKING_DIRECTORY ${JEMALLOC_ROOT_DIR})
add_custom_command(OUTPUT "${JEMALLOC_ROOT_DIR}/lib/libjemalloc.a"
"${JEMALLOC_ROOT_DIR}/lib/libjemalloc.so"
Expand Down
2 changes: 2 additions & 0 deletions mkreleasehdr.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1`
GIT_DIRTY=`git diff --no-ext-diff 2> /dev/null | wc -l`
BUILD_ID=`uname -n`"-"`date +%s`
Expand Down Expand Up @@ -36,3 +37,4 @@ echo "#endif // SRC_TENDISPLUS_COMMANDS_RELEASE_H_" >> ${h_file}


touch ${c_file} # Force recompile of release.c

26 changes: 26 additions & 0 deletions src/tendisplus/commands/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <thread> // NOLINT
#include <chrono> // NOLINT
#include "glog/logging.h"
#include "jemalloc/jemalloc.h"
#include "rapidjson/document.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"
Expand Down Expand Up @@ -4380,4 +4381,29 @@ class adminDelCommand : public Command {
}
} admindelCmd;

class JeprofCommand : public Command {
public:
JeprofCommand() : Command("jeprof", "a") {}

ssize_t arity() const {
return 1;
}

int32_t firstkey() const {
return 0;
}

int32_t lastkey() const {
return 0;
}

int32_t keystep() const {
return 0;
}
Expected<std::string> run(Session* sess) final {
mallctl("prof.dump", NULL, NULL, NULL, 0);
return Command::fmtOK();
}
} jeprofCommand;

} // namespace tendisplus

0 comments on commit 1af8b76

Please sign in to comment.