This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 726c8d13831 [chore](memory) remove memory tracker hook code and
simplify cpu controller code (#53794)
726c8d13831 is described below
commit 726c8d13831e3fb45ca2132b2f41efa34e70808a
Author: yiguolei <[email protected]>
AuthorDate: Fri Jul 25 22:34:28 2025 +0800
[chore](memory) remove memory tracker hook code and simplify cpu controller
code (#53794)
---
be/src/agent/cgroup_cpu_ctl.cpp | 20 +-
be/src/agent/cgroup_cpu_ctl.h | 4 -
be/src/runtime/CMakeLists.txt | 4 -
be/src/runtime/exec_env_init.cpp | 4 -
be/src/runtime/memory/jemalloc_hook.cpp | 227 ---------------------
be/src/runtime/memory/tcmalloc_hook.h | 66 ------
be/src/runtime/thread_context.h | 44 ----
be/src/runtime/workload_group/workload_group.cpp | 4 +-
.../workload_group/workload_group_manager.cpp | 2 +
cloud/src/common/jemalloc_hook.cpp | 131 ------------
10 files changed, 16 insertions(+), 490 deletions(-)
diff --git a/be/src/agent/cgroup_cpu_ctl.cpp b/be/src/agent/cgroup_cpu_ctl.cpp
index 972ccc7aae4..3bff9ebc33f 100644
--- a/be/src/agent/cgroup_cpu_ctl.cpp
+++ b/be/src/agent/cgroup_cpu_ctl.cpp
@@ -184,6 +184,9 @@ void CgroupCpuCtl::update_cpu_hard_limit(int
cpu_hard_limit) {
Status ret = modify_cg_cpu_hard_limit_no_lock(cpu_hard_limit);
if (ret.ok()) {
_cpu_hard_limit = cpu_hard_limit;
+ } else {
+ LOG(WARNING) << "update cpu hard limit failed, cpu hard limit: "
<< cpu_hard_limit
+ << ", error: " << ret;
}
}
}
@@ -337,8 +340,10 @@ Status
CgroupV1CpuCtl::modify_cg_cpu_soft_limit_no_lock(int cpu_shares) {
}
Status CgroupV1CpuCtl::modify_cg_cpu_hard_limit_no_lock(int cpu_hard_limit) {
- uint64_t val = cpu_hard_limit > 0 ? (_cpu_cfs_period_us * _cpu_core_num *
cpu_hard_limit / 100)
- : CGROUP_CPU_HARD_LIMIT_DEFAULT_VALUE;
+ if (cpu_hard_limit <= 0) {
+ return Status::InternalError<false>("cpu hard limit must be greater
than 0");
+ }
+ uint64_t val = _cpu_cfs_period_us * _cpu_core_num * cpu_hard_limit / 100;
std::string str_val = std::to_string(val);
std::string msg = "modify cpu quota value to " + str_val;
return CgroupCpuCtl::write_cg_sys_file(_cgroup_v1_cpu_tg_quota_file,
str_val, msg, false);
@@ -399,13 +404,12 @@ Status CgroupV2CpuCtl::init() {
}
Status CgroupV2CpuCtl::modify_cg_cpu_hard_limit_no_lock(int cpu_hard_limit) {
- std::string value = "";
- if (cpu_hard_limit > 0) {
- uint64_t int_val = _cpu_cfs_period_us * _cpu_core_num * cpu_hard_limit
/ 100;
- value = std::to_string(int_val) + " 100000";
- } else {
- value = CGROUP_V2_CPU_HARD_LIMIT_DEFAULT_VALUE;
+ if (cpu_hard_limit <= 0) {
+ return Status::InternalError<false>("cpu hard limit must be greater
than 0");
}
+ std::string value = "";
+ uint64_t int_val = _cpu_cfs_period_us * _cpu_core_num * cpu_hard_limit /
100;
+ value = std::to_string(int_val) + " 100000";
std::string msg = "modify cpu.max to [" + value + "]";
return CgroupCpuCtl::write_cg_sys_file(_cgroup_v2_query_wg_cpu_max_file,
value, msg, false);
}
diff --git a/be/src/agent/cgroup_cpu_ctl.h b/be/src/agent/cgroup_cpu_ctl.h
index b23f1f4dd9c..85feeb73d60 100644
--- a/be/src/agent/cgroup_cpu_ctl.h
+++ b/be/src/agent/cgroup_cpu_ctl.h
@@ -28,10 +28,6 @@
namespace doris {
-// cgroup cpu.cfs_quota_us default value, it means disable cpu hard limit
-const static int CGROUP_CPU_HARD_LIMIT_DEFAULT_VALUE = -1;
-const static std::string CGROUP_V2_CPU_HARD_LIMIT_DEFAULT_VALUE = "max 100000";
-
class CgroupCpuCtl {
public:
virtual ~CgroupCpuCtl() = default;
diff --git a/be/src/runtime/CMakeLists.txt b/be/src/runtime/CMakeLists.txt
index 7d54f9bd76b..7b5d3f31962 100644
--- a/be/src/runtime/CMakeLists.txt
+++ b/be/src/runtime/CMakeLists.txt
@@ -25,10 +25,6 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/runtime")
file(GLOB_RECURSE RUNTIME_FILES CONFIGURE_DEPENDS *.cpp *.cc)
-if (NOT USE_JEMALLOC OR OS_MACOSX)
- list(REMOVE_ITEM RUNTIME_FILES
${CMAKE_CURRENT_SOURCE_DIR}/memory/jemalloc_hook.cpp)
-endif()
-
add_library(Runtime STATIC
${RUNTIME_FILES}
)
diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index ce6e6179dea..78ab91a6fc8 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -129,8 +129,6 @@
#include "io/fs/hdfs/hdfs_mgr.h"
// clang-format on
-#include "runtime/memory/tcmalloc_hook.h"
-
namespace doris {
#include "common/compile_check_begin.h"
@@ -477,8 +475,6 @@ Status ExecEnv::_init_mem_env() {
init_mem_tracker();
thread_context()->thread_mem_tracker_mgr->init();
- init_hook();
-
if (!BitUtil::IsPowerOf2(config::min_buffer_size)) {
ss << "Config min_buffer_size must be a power-of-two: " <<
config::min_buffer_size;
return Status::InternalError(ss.str());
diff --git a/be/src/runtime/memory/jemalloc_hook.cpp
b/be/src/runtime/memory/jemalloc_hook.cpp
deleted file mode 100644
index 6699c84786e..00000000000
--- a/be/src/runtime/memory/jemalloc_hook.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <features.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "common/compiler_util.h" // IWYU pragma: keep
-#include "jemalloc/jemalloc.h"
-#include "runtime/thread_context.h"
-#include "util/sse_util.hpp"
-
-#ifndef __THROW
-#if __cplusplus
-#define __THROW noexcept
-#else
-#define __THROW
-#endif
-#endif
-
-extern "C" {
-
-// Both je_nallocx and je_malloc will use the lock je_malloc_mutex_lock_slow,
-// so enabling the jemalloc hook will double the lock usage.
-// In extreme cases this will affect performance, consider turning off mem hook
-// mem hook should avoid nesting new/malloc.
-
-void* doris_malloc(size_t size) __THROW {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN([](size_t size) { return
jenallocx(size, 0); },
- size);
- void* ptr = jemalloc(size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN([](size_t size) { return
jenallocx(size, 0); },
- size);
- }
- return ptr;
-}
-
-void doris_free(void* p) __THROW {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN([](void* p) { return
jemalloc_usable_size(p); }, p);
- jefree(p);
-}
-
-void* doris_realloc(void* p, size_t size) __THROW {
- if (UNLIKELY(size == 0)) {
- return nullptr;
- }
-
-#ifndef BE_TEST
- int64_t old_size = jemalloc_usable_size(p);
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](size_t size, int64_t old_size) { return jenallocx(size, 0) -
old_size; }, size,
- old_size);
- void* ptr = jerealloc(p, size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](size_t size, int64_t old_size) { return jenallocx(size, 0)
- old_size; }, size,
- old_size);
- }
- return ptr;
-#else
- void* ptr = jerealloc(p, size);
- return ptr;
-#endif
-}
-
-void* doris_calloc(size_t n, size_t size) __THROW {
- if (UNLIKELY(size == 0)) {
- return nullptr;
- }
-
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(n * size);
- void* ptr = jecalloc(n, size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(n * size);
- } else {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](void* ptr, size_t size) { return jemalloc_usable_size(ptr)
- size; }, ptr,
- n * size);
- }
- return ptr;
-}
-
-void doris_cfree(void* ptr) __THROW {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN([](void* ptr) { return
jemalloc_usable_size(ptr); },
- ptr);
- jefree(ptr);
-}
-
-void* doris_memalign(size_t align, size_t size) __THROW {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size);
- void* ptr = jealigned_alloc(align, size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size);
- } else {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](void* ptr, size_t size) { return jemalloc_usable_size(ptr)
- size; }, ptr, size);
- }
- return ptr;
-}
-
-void* doris_aligned_alloc(size_t align, size_t size) __THROW {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size);
- void* ptr = jealigned_alloc(align, size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size);
- } else {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](void* ptr, size_t size) { return jemalloc_usable_size(ptr)
- size; }, ptr, size);
- }
- return ptr;
-}
-
-void* doris_valloc(size_t size) __THROW {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size);
- void* ptr = jevalloc(size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size);
- } else {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](void* ptr, size_t size) { return jemalloc_usable_size(ptr)
- size; }, ptr, size);
- }
- return ptr;
-}
-
-void* doris_pvalloc(size_t size) __THROW {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size);
- void* ptr = jevalloc(size);
- if (UNLIKELY(ptr == nullptr)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size);
- } else {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](void* ptr, size_t size) { return jemalloc_usable_size(ptr)
- size; }, ptr, size);
- }
- return ptr;
-}
-
-int doris_posix_memalign(void** r, size_t align, size_t size) __THROW {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size);
- int ret = jeposix_memalign(r, align, size);
- if (UNLIKELY(ret != 0)) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size);
- } else {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
- [](void* ptr, size_t size) { return jemalloc_usable_size(ptr)
- size; }, *r, size);
- }
- return ret;
-}
-
-size_t doris_malloc_usable_size(void* ptr) __THROW {
- size_t ret = jemalloc_usable_size(ptr);
- return ret;
-}
-
-#ifndef __APPLE__
-#define ALIAS(doris_fn) __attribute__((alias(#doris_fn), used))
-void* malloc(size_t size) __THROW ALIAS(doris_malloc);
-void free(void* p) __THROW ALIAS(doris_free);
-void* realloc(void* p, size_t size) __THROW ALIAS(doris_realloc);
-void* calloc(size_t n, size_t size) __THROW ALIAS(doris_calloc);
-void cfree(void* ptr) __THROW ALIAS(doris_cfree);
-void* memalign(size_t align, size_t size) __THROW ALIAS(doris_memalign);
-void* aligned_alloc(size_t align, size_t size) __THROW
ALIAS(doris_aligned_alloc);
-void* valloc(size_t size) __THROW ALIAS(doris_valloc);
-void* pvalloc(size_t size) __THROW ALIAS(doris_pvalloc);
-int posix_memalign(void** r, size_t a, size_t s) __THROW
ALIAS(doris_posix_memalign);
-size_t malloc_usable_size(void* ptr) __THROW ALIAS(doris_malloc_usable_size);
-#else
-void* malloc(size_t size) {
- return doris_malloc(size);
-}
-
-void free(void* p) {
- return doris_free(p);
-}
-
-void* realloc(void* p, size_t size) {
- return doris_realloc(p, size);
-}
-
-void* calloc(size_t n, size_t size) {
- return doris_calloc(n, size);
-}
-
-void cfree(void* ptr) {
- return doris_cfree(ptr);
-}
-
-void* memalign(size_t align, size_t size) {
- return doris_memalign(align, size);
-}
-
-void* aligned_alloc(size_t align, size_t size) {
- return doris_aligned_alloc(align, size);
-}
-
-void* valloc(size_t size) {
- return doris_valloc(size);
-}
-
-void* pvalloc(size_t size) {
- return doris_pvalloc(size);
-}
-
-int posix_memalign(void** r, size_t a, size_t s) {
- return doris_posix_memalign(r, a, s);
-}
-
-size_t malloc_usable_size(void* ptr) {
- return doris_malloc_usable_size(ptr);
-}
-#endif
-}
diff --git a/be/src/runtime/memory/tcmalloc_hook.h
b/be/src/runtime/memory/tcmalloc_hook.h
deleted file mode 100644
index 36b292bf1ad..00000000000
--- a/be/src/runtime/memory/tcmalloc_hook.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#pragma once
-
-#include <cstddef>
-
-#if !defined(__APPLE__) && !defined(__SANITIZE_ADDRESS__) &&
!defined(ADDRESS_SANITIZER) && \
- !defined(LEAK_SANITIZER) && !defined(THREAD_SANITIZER) &&
!defined(USE_JEMALLOC)
-#include <gperftools/malloc_hook.h>
-#include <gperftools/nallocx.h>
-#include <gperftools/tcmalloc.h>
-
-#include "runtime/thread_context.h"
-
-// Notice: modify the command in New/Delete Hook should be careful enough!,
-// and should be as simple as possible, otherwise it may cause weird errors.
E.g:
-// 1. The first New Hook call of the process may be before some variables of
-// the process are initialized.
-// 2. Allocating memory in the Hook command causes the Hook to be entered
again,
-// infinite recursion.
-// 3. TCMalloc hook will be triggered during the process of
initializing/Destructor
-// memtracker shared_ptr, Using the object pointed to by this memtracker
shared_ptr
-// in TCMalloc hook may cause crash.
-// 4. Modifying additional thread local variables in ThreadContext
construction and
-// destructor to control the behavior of consume can lead to unexpected
behavior,
-// like this: if (LIKELY(doris::start_thread_mem_tracker)) {
-void new_hook(const void* ptr, size_t size) {
- CONSUME_THREAD_MEM_TRACKER_BY_HOOK(tc_nallocx(size, 0));
-}
-
-void delete_hook(const void* ptr) {
- RELEASE_THREAD_MEM_TRACKER_BY_HOOK(tc_malloc_size(const_cast<void*>(ptr)));
-}
-
-void init_hook() {
- MallocHook::AddNewHook(&new_hook);
- MallocHook::AddDeleteHook(&delete_hook);
-}
-
-// For later debug.
-// static void destroy_hook() {
-// MallocHook::RemoveNewHook(&new_hook);
-// MallocHook::RemoveDeleteHook(&delete_hook);
-// }
-
-#else
-void new_hook(const void* ptr, size_t size) {}
-void delete_hook(const void* ptr) {}
-void init_hook() {}
-
-#endif
diff --git a/be/src/runtime/thread_context.h b/be/src/runtime/thread_context.h
index 967c08dd3e3..94f50b48d17 100644
--- a/be/src/runtime/thread_context.h
+++ b/be/src/runtime/thread_context.h
@@ -406,50 +406,6 @@ public:
};
// Basic macros for mem tracker, usually do not need to be modified and used.
-
-// used to fix the tracking accuracy of caches.
-#define THREAD_MEM_TRACKER_TRANSFER_TO(size, tracker)
\
- do {
\
- DCHECK(doris::k_doris_exit ||
!doris::config::enable_memory_orphan_check || \
-
doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()->label()
!= \
- "Orphan")
\
- << doris::MEMORY_ORPHAN_CHECK_MSG;
\
-
doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()->transfer_to(
\
- size, tracker);
\
- } while (0)
-
-#define THREAD_MEM_TRACKER_TRANSFER_FROM(size, tracker)
\
- do {
\
- DCHECK(doris::k_doris_exit ||
!doris::config::enable_memory_orphan_check || \
-
doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()->label()
!= \
- "Orphan")
\
- << doris::MEMORY_ORPHAN_CHECK_MSG;
\
- tracker->transfer_to(
\
- size,
doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()); \
- } while (0)
-
-// Mem Hook to consume thread mem tracker
-#define CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size) \
- do { \
- if (doris::use_mem_hook) { \
- doris::thread_context()->thread_mem_tracker_mgr->consume(size); \
- } \
- } while (0)
-#define RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size)
CONSUME_THREAD_MEM_TRACKER_BY_HOOK(-size)
-#define CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(size_fn, ...)
\
- do {
\
- if (doris::use_mem_hook) {
\
-
doris::thread_context()->thread_mem_tracker_mgr->consume(size_fn(__VA_ARGS__));
\
- }
\
- } while (0)
-#define RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(size_fn, ...)
\
- do {
\
- if (doris::use_mem_hook) {
\
-
doris::thread_context()->thread_mem_tracker_mgr->consume(-size_fn(__VA_ARGS__));
\
- }
\
- } while (0)
-
-// if use mem hook, avoid repeated consume.
// must call create_thread_local_if_not_exits() before use thread_context().
#define CONSUME_THREAD_MEM_TRACKER(size)
\
do {
\
diff --git a/be/src/runtime/workload_group/workload_group.cpp
b/be/src/runtime/workload_group/workload_group.cpp
index d3d52b52db1..96d68a87605 100644
--- a/be/src/runtime/workload_group/workload_group.cpp
+++ b/be/src/runtime/workload_group/workload_group.cpp
@@ -49,9 +49,9 @@ namespace doris {
#include "common/compile_check_begin.h"
-const static std::string MEMORY_LIMIT_DEFAULT_VALUE = "0%";
+const static std::string MEMORY_LIMIT_DEFAULT_VALUE = "100%";
const static bool ENABLE_MEMORY_OVERCOMMIT_DEFAULT_VALUE = true;
-const static int CPU_HARD_LIMIT_DEFAULT_VALUE = -1;
+const static int CPU_HARD_LIMIT_DEFAULT_VALUE = 100;
const static int MEMORY_LOW_WATERMARK_DEFAULT_VALUE = 80;
const static int MEMORY_HIGH_WATERMARK_DEFAULT_VALUE = 95;
diff --git a/be/src/runtime/workload_group/workload_group_manager.cpp
b/be/src/runtime/workload_group/workload_group_manager.cpp
index bb7d6dc180d..5ad8bd1e07e 100644
--- a/be/src/runtime/workload_group/workload_group_manager.cpp
+++ b/be/src/runtime/workload_group/workload_group_manager.cpp
@@ -1056,6 +1056,8 @@ Status WorkloadGroupMgr::create_internal_wg() {
TWorkloadGroupInfo twg_info;
twg_info.__set_id(INTERNAL_NORMAL_WG_ID);
twg_info.__set_name(INTERNAL_NORMAL_WG_NAME);
+ twg_info.__set_mem_limit("100%"); // The normal wg will occupy all
memory by default.
+ twg_info.__set_cpu_hard_limit(100); // Means disable cpu hard limit for
cgroup
twg_info.__set_version(0);
WorkloadGroupInfo wg_info = WorkloadGroupInfo::parse_topic_info(twg_info);
diff --git a/cloud/src/common/jemalloc_hook.cpp
b/cloud/src/common/jemalloc_hook.cpp
deleted file mode 100644
index 88380bab41c..00000000000
--- a/cloud/src/common/jemalloc_hook.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "jemalloc/jemalloc.h"
-
-#ifndef __THROW
-#if __cplusplus
-#define __THROW noexcept
-#else
-#define __THROW
-#endif
-#endif
-
-extern "C" {
-void* doris_malloc(size_t size) __THROW {
- return jemalloc(size);
-}
-
-void doris_free(void* p) __THROW {
- jefree(p);
-}
-
-void* doris_realloc(void* p, size_t size) __THROW {
- return jerealloc(p, size);
-}
-
-void* doris_calloc(size_t n, size_t size) __THROW {
- return jecalloc(n, size);
-}
-
-void doris_cfree(void* ptr) __THROW {
- jefree(ptr);
-}
-
-void* doris_memalign(size_t align, size_t size) __THROW {
- return jealigned_alloc(align, size);
-}
-
-void* doris_aligned_alloc(size_t align, size_t size) __THROW {
- return jealigned_alloc(align, size);
-}
-
-void* doris_valloc(size_t size) __THROW {
- return jevalloc(size);
-}
-
-void* doris_pvalloc(size_t size) __THROW {
- return jevalloc(size);
-}
-
-int doris_posix_memalign(void** r, size_t align, size_t size) __THROW {
- return jeposix_memalign(r, align, size);
-}
-
-size_t doris_malloc_usable_size(void* ptr) __THROW {
- return jemalloc_usable_size(ptr);
-}
-
-#ifndef __APPLE__
-#define ALIAS(doris_fn) __attribute__((alias(#doris_fn), used))
-void* malloc(size_t size) __THROW ALIAS(doris_malloc);
-void free(void* p) __THROW ALIAS(doris_free);
-void* realloc(void* p, size_t size) __THROW ALIAS(doris_realloc);
-void* calloc(size_t n, size_t size) __THROW ALIAS(doris_calloc);
-void cfree(void* ptr) __THROW ALIAS(doris_cfree);
-void* memalign(size_t align, size_t size) __THROW ALIAS(doris_memalign);
-void* aligned_alloc(size_t align, size_t size) __THROW
ALIAS(doris_aligned_alloc);
-void* valloc(size_t size) __THROW ALIAS(doris_valloc);
-void* pvalloc(size_t size) __THROW ALIAS(doris_pvalloc);
-int posix_memalign(void** r, size_t a, size_t s) __THROW
ALIAS(doris_posix_memalign);
-size_t malloc_usable_size(void* ptr) __THROW ALIAS(doris_malloc_usable_size);
-#else
-void* malloc(size_t size) {
- return doris_malloc(size);
-}
-
-void free(void* p) {
- return doris_free(p);
-}
-
-void* realloc(void* p, size_t size) {
- return doris_realloc(p, size);
-}
-
-void* calloc(size_t n, size_t size) {
- return doris_calloc(n, size);
-}
-
-void cfree(void* ptr) {
- return doris_cfree(ptr);
-}
-
-void* memalign(size_t align, size_t size) {
- return doris_memalign(align, size);
-}
-
-void* aligned_alloc(size_t align, size_t size) {
- return doris_aligned_alloc(align, size);
-}
-
-void* valloc(size_t size) {
- return doris_valloc(size);
-}
-
-void* pvalloc(size_t size) {
- return doris_pvalloc(size);
-}
-
-int posix_memalign(void** r, size_t a, size_t s) {
- return doris_posix_memalign(r, a, s);
-}
-
-size_t malloc_usable_size(void* ptr) {
- return doris_malloc_usable_size(ptr);
-}
-#endif
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]