[feature] (memory) Switch TLS mem tracker to separate more detailed memory usage (#8605)
In pr #8476, all memory usage of a process is recorded in the process mem tracker, and all memory usage of a query is recorded in the query mem tracker, and it is still necessary to manually call `transfer to` to track the cached memory size. We hope to separate out more detailed memory usage based on Hook TCMalloc new/delete + TLS mem tracker. In this pr, the more detailed mem tracker is switched to TLS, which automatically and accurately counts more detailed memory usage than before.
This commit is contained in:
@ -53,7 +53,6 @@
|
||||
#include "runtime/exec_env.h"
|
||||
#include "runtime/heartbeat_flags.h"
|
||||
#include "runtime/minidump.h"
|
||||
#include "runtime/tcmalloc_hook.h"
|
||||
#include "service/backend_options.h"
|
||||
#include "service/backend_service.h"
|
||||
#include "service/brpc_service.h"
|
||||
@ -65,6 +64,11 @@
|
||||
#include "util/thrift_server.h"
|
||||
#include "util/uid_util.h"
|
||||
|
||||
#if !defined(__SANITIZE_ADDRESS__) && !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \
|
||||
!defined(THREAD_SANITIZER)
|
||||
#include "runtime/tcmalloc_hook.h"
|
||||
#endif
|
||||
|
||||
static void help(const char*);
|
||||
|
||||
#include <dlfcn.h>
|
||||
@ -336,11 +340,8 @@ int main(int argc, char** argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (doris::config::track_new_delete) {
|
||||
init_hook();
|
||||
}
|
||||
|
||||
#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && !defined(THREAD_SANITIZER)
|
||||
#if !defined(__SANITIZE_ADDRESS__) && !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \
|
||||
!defined(THREAD_SANITIZER)
|
||||
// Aggressive decommit is required so that unused pages in the TCMalloc page heap are
|
||||
// not backed by physical pages and do not contribute towards memory consumption.
|
||||
MallocExtension::instance()->SetNumericProperty("tcmalloc.aggressive_memory_decommit", 1);
|
||||
@ -351,6 +352,9 @@ int main(int argc, char** argv) {
|
||||
fprintf(stderr, "Failed to change TCMalloc total thread cache size.\n");
|
||||
return -1;
|
||||
}
|
||||
if (doris::config::track_new_delete) {
|
||||
init_hook();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!doris::Env::init()) {
|
||||
|
||||
Reference in New Issue
Block a user