Skip to content

Commit

Permalink
Proxy: Reduce proxy's size by compressing some debug sections (#8915)
Browse files Browse the repository at this point in the history
close #7256
  • Loading branch information
CalvinNeo authored Apr 9, 2024
1 parent 35e0a1e commit 6bd9e6b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
21 changes: 21 additions & 0 deletions contrib/tiflash-proxy-cmake/tiflash_proxy_linux_post_install.cmake
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions dbms/src/Server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}/")
Expand Down
10 changes: 9 additions & 1 deletion dbms/src/Storages/KVStore/KVStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(data.alloc) - static_cast<int64_t>(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);
}
Expand Down

0 comments on commit 6bd9e6b

Please sign in to comment.