mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #64592 from tomershafir/xray
xray: add global xray instrumentation support
This commit is contained in:
commit
5a5bdd87cb
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,6 +21,9 @@
|
|||||||
*.stderr
|
*.stderr
|
||||||
*.stdout
|
*.stdout
|
||||||
|
|
||||||
|
# llvm-xray logs
|
||||||
|
xray-log.*
|
||||||
|
|
||||||
/docs/build
|
/docs/build
|
||||||
/docs/publish
|
/docs/publish
|
||||||
/docs/edit
|
/docs/edit
|
||||||
|
@ -122,6 +122,8 @@ add_library(global-libs INTERFACE)
|
|||||||
|
|
||||||
include (cmake/sanitize.cmake)
|
include (cmake/sanitize.cmake)
|
||||||
|
|
||||||
|
include (cmake/instrument.cmake)
|
||||||
|
|
||||||
option(ENABLE_COLORED_BUILD "Enable colors in compiler output" ON)
|
option(ENABLE_COLORED_BUILD "Enable colors in compiler output" ON)
|
||||||
|
|
||||||
set (CMAKE_COLOR_MAKEFILE ${ENABLE_COLORED_BUILD}) # works only for the makefile generator
|
set (CMAKE_COLOR_MAKEFILE ${ENABLE_COLORED_BUILD}) # works only for the makefile generator
|
||||||
|
20
cmake/instrument.cmake
Normal file
20
cmake/instrument.cmake
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# https://llvm.org/docs/XRay.html
|
||||||
|
|
||||||
|
option (ENABLE_XRAY "Enable LLVM XRay" OFF)
|
||||||
|
|
||||||
|
if (NOT ENABLE_XRAY)
|
||||||
|
message (STATUS "Not using LLVM XRay")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT (ARCH_AMD64 AND (OS_LINUX OR OS_FREEBSD)))
|
||||||
|
message (STATUS "Not using LLVM XRay, only amd64 Linux or FreeBSD are supported")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The target clang must support xray, otherwise it should error on invalid option
|
||||||
|
set (XRAY_FLAGS "-fxray-instrument -DUSE_XRAY")
|
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XRAY_FLAGS}")
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XRAY_FLAGS}")
|
||||||
|
|
||||||
|
message (STATUS "Using LLVM XRay")
|
@ -742,6 +742,7 @@ std::string BaseDaemon::getDefaultConfigFileName() const
|
|||||||
|
|
||||||
void BaseDaemon::closeFDs()
|
void BaseDaemon::closeFDs()
|
||||||
{
|
{
|
||||||
|
#if !defined(USE_XRAY)
|
||||||
/// NOTE: may benefit from close_range() (linux 5.9+)
|
/// NOTE: may benefit from close_range() (linux 5.9+)
|
||||||
#if defined(OS_FREEBSD) || defined(OS_DARWIN)
|
#if defined(OS_FREEBSD) || defined(OS_DARWIN)
|
||||||
fs::path proc_path{"/dev/fd"};
|
fs::path proc_path{"/dev/fd"};
|
||||||
@ -789,13 +790,13 @@ void BaseDaemon::closeFDs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseDaemon::initialize(Application & self)
|
void BaseDaemon::initialize(Application & self)
|
||||||
{
|
{
|
||||||
closeFDs();
|
closeFDs();
|
||||||
|
|
||||||
ServerApplication::initialize(self);
|
ServerApplication::initialize(self);
|
||||||
|
|
||||||
/// now highest priority (lowest value) is PRIO_APPLICATION = -100, we want higher!
|
/// now highest priority (lowest value) is PRIO_APPLICATION = -100, we want higher!
|
||||||
|
Loading…
Reference in New Issue
Block a user