diff --git a/contrib/tiflash-proxy-cmake/tiflash_proxy_linux_post_install.cmake b/contrib/tiflash-proxy-cmake/tiflash_proxy_linux_post_install.cmake new file mode 100644 index 00000000000..d3cc3d40c56 --- /dev/null +++ b/contrib/tiflash-proxy-cmake/tiflash_proxy_linux_post_install.cmake @@ -0,0 +1,21 @@ +# Copyright 2024 PingCAP, Inc. +# +# Licensed 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. + +find_program(OBJCOPY_EXECUTABLE "objcopy") +if(OBJCOPY_EXECUTABLE) + message(STATUS "Compressing debug sections for ${CMAKE_INSTALL_PREFIX}/tiflash-proxy...") + execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --compress-debug-sections=zlib-gnu ${CMAKE_INSTALL_PREFIX}/libtiflash_proxy.so) +else() + message(WARNING "objcopy not found in PATH. Skipped debug section compression for proxy.") +endif() \ No newline at end of file diff --git a/dbms/src/Server/CMakeLists.txt b/dbms/src/Server/CMakeLists.txt index e8783a87b12..71dc5441af4 100644 --- a/dbms/src/Server/CMakeLists.txt +++ b/dbms/src/Server/CMakeLists.txt @@ -129,6 +129,7 @@ if (OS_LINUX) if (NOT (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR SAN_DEBUG)) install (SCRIPT ${TiFlash_SOURCE_DIR}/cmake/tiflash_linux_post_install.cmake COMPONENT tiflash-release) endif() + install (SCRIPT ${TiFlash_SOURCE_DIR}/contrib/tiflash-proxy-cmake/tiflash_proxy_linux_post_install.cmake COMPONENT tiflash-release) elseif(APPLE) # set build rpaths, so that executables can be directly called in build tree (easy to debug) set_target_properties(tiflash PROPERTIES BUILD_RPATH "@executable_path/;@executable_path/${TIFLASH_PROXY_LIB_RPATH}/") diff --git a/dbms/src/Storages/KVStore/KVStore.cpp b/dbms/src/Storages/KVStore/KVStore.cpp index 364aa30e149..9ff701d1a45 100644 --- a/dbms/src/Storages/KVStore/KVStore.cpp +++ b/dbms/src/Storages/KVStore/KVStore.cpp @@ -589,7 +589,15 @@ void KVStore::reportThreadAllocBatch(std::string_view name, ReportThreadAllocate return; // TODO(jemalloc-trace) Could be costy. auto k = getThreadNameAggPrefix(name); - int64_t v = static_cast(data.alloc) - static_cast(data.dealloc); + int64_t v = 0; + if (data.alloc > data.dealloc) + { + v = data.alloc - data.dealloc; + } + else + { + v = -(data.dealloc - data.alloc); + } auto & tiflash_metrics = TiFlashMetrics::instance(); tiflash_metrics.setProxyThreadMemory(k, v); }