Permalink
Browse files

Start jemalloc background threads manually after hugifyText

Summary:
We cannot have threads running when remapping hottext, so don't create background threads automatically.

The background threads are only created for server mode, after hugefyText.  Script mode won't have it, which I think is fine.

When running against older versions of jemalloc (in some OSS builds), the mallctl will fail, and we log a line, but nothing bad happens.

Reviewed By: markw65

Differential Revision: D7054160

fbshipit-source-id: 3e7e8d2f093d683270959cd240a9fa21d4f7df53
  • Loading branch information...
binliu19 authored and hhvm-bot committed Feb 24, 2018
1 parent e973358 commit cc86a98f44236ab0b532a7a6a455085f08b7ffee
Showing with 11 additions and 2 deletions.
  1. +8 −0 hphp/runtime/base/program-functions.cpp
  2. +3 −2 hphp/util/alloc.cpp
@@ -76,6 +76,7 @@
#include "hphp/runtime/vm/treadmill.h"
#include "hphp/util/abi-cxx.h"
#include "hphp/util/alloc.h"
#include "hphp/util/arch.h"
#include "hphp/util/boot-stats.h"
#include "hphp/util/build-info.h"
@@ -2263,6 +2264,13 @@ void hphp_process_init() {
hphp_process_exit();
exit(0);
}
#if defined(USE_JEMALLOC) && (JEMALLOC_VERSION_MAJOR >= 5)
// jemalloc 5 has background threads, which handle purging asynchronously.
if (mallctlWrite("background_thread", true, /* errorOK */ true)) {
Logger::Warning("Failed to enable jemalloc background threads");
}
#endif
}
static void handle_exception(bool& ret, ExecutionContext* context,
@@ -782,9 +782,10 @@ void thread_huge_tcache_destroy() {
extern "C" {
const char* malloc_conf = "narenas:1,lg_tcache_max:16"
#if (JEMALLOC_VERSION_MAJOR >= 5)
// FB-only as this feature does not exist in any jemalloc release as of
// 2017-11-02 (latest: 5.0.1)
",background_thread:false"
#ifdef FACEBOOK
// FB-only as this feature does not exist in any jemalloc release as of
// 2017-11-02 (latest: 5.0.1)
",metadata_thp:disabled"
#endif
#endif

0 comments on commit cc86a98

Please sign in to comment.