2018-04-13 16:33:46 +08:00
|
|
|
# Build for all components of the XRay runtime support library.
|
2016-07-21 15:39:55 +08:00
|
|
|
|
[XRay][compiler-rt] XRay Flight Data Recorder Mode
Summary:
In this change we introduce the notion of a "flight data recorder" mode
for XRay logging, where XRay logs in-memory first, and write out data
on-demand as required (as opposed to the naive implementation that keeps
logging while tracing is "on"). This depends on D26232 where we
implement the core data structure for holding the buffers that threads
will be using to write out records of operation.
This implementation only currently works on x86_64 and depends heavily
on the TSC math to write out smaller records to the inmemory buffers.
Also, this implementation defines two different kinds of records with
different sizes (compared to the current naive implementation): a
MetadataRecord (16 bytes) and a FunctionRecord (8 bytes). MetadataRecord
entries are meant to write out information like the thread ID for which
the metadata record is defined for, whether the execution of a thread
moved to a different CPU, etc. while a FunctionRecord represents the
different kinds of function call entry/exit records we might encounter
in the course of a thread's execution along with a delta from the last
time the logging handler was called.
While this implementation is not exactly what is described in the
original XRay whitepaper, this one gives us an initial implementation
that we can iterate and build upon.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D27038
llvm-svn: 293015
2017-01-25 11:50:46 +08:00
|
|
|
# XRay runtime library implementation files.
|
2016-07-21 15:39:55 +08:00
|
|
|
set(XRAY_SOURCES
|
[XRay][profiler] Part 1: XRay Allocator and Array Implementations
Summary:
This change is part of the larger XRay Profiling Mode effort.
Here we implement an arena allocator, for fixed sized buffers used in a
segmented array implementation. This change adds the segmented array
data structure, which relies on the allocator to provide and maintain
the storage for the segmented array.
Key features of the `Allocator` type:
* It uses cache-aligned blocks, intended to host the actual data. These
blocks are cache-line-size multiples of contiguous bytes.
* The `Allocator` has a maximum memory budget, set at construction
time. This allows us to cap the amount of data each specific
`Allocator` instance is responsible for.
* Upon destruction, the `Allocator` will clean up the storage it's
used, handing it back to the internal allocator used in
sanitizer_common.
Key features of the `Array` type:
* Each segmented array is always backed by an `Allocator`, which is
either user-provided or uses a global allocator.
* When an `Array` grows, it grows by appending a segment that's
fixed-sized. The size of each segment is computed by the number of
elements of type `T` that can fit into cache line multiples.
* An `Array` does not return memory to the `Allocator`, but it can keep
track of the current number of "live" objects it stores.
* When an `Array` is destroyed, it will not return memory to the
`Allocator`. Users should clean up the `Allocator` independently of
the `Array`.
* The `Array` type keeps a freelist of the chunks it's used before, so
that trimming and growing will re-use previously allocated chunks.
These basic data structures are used by the XRay Profiling Mode
implementation to implement efficient and cache-aware storage for data
that's typically read-and-write heavy for tracking latency information.
We're relying on the cache line characteristics of the architecture to
provide us good data isolation and cache friendliness, when we're
performing operations like searching for elements and/or updating data
hosted in these cache lines.
Reviewers: echristo, pelikan, kpw
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D45756
llvm-svn: 331141
2018-04-29 21:46:30 +08:00
|
|
|
xray_init.cc
|
|
|
|
xray_flags.cc
|
|
|
|
xray_interface.cc
|
|
|
|
xray_log_interface.cc
|
|
|
|
xray_utils.cc)
|
2016-07-21 15:39:55 +08:00
|
|
|
|
2018-04-13 16:33:46 +08:00
|
|
|
# Implementation files for all XRay modes.
|
2018-04-11 09:28:25 +08:00
|
|
|
set(XRAY_FDR_MODE_SOURCES
|
[XRay][profiler] Part 1: XRay Allocator and Array Implementations
Summary:
This change is part of the larger XRay Profiling Mode effort.
Here we implement an arena allocator, for fixed sized buffers used in a
segmented array implementation. This change adds the segmented array
data structure, which relies on the allocator to provide and maintain
the storage for the segmented array.
Key features of the `Allocator` type:
* It uses cache-aligned blocks, intended to host the actual data. These
blocks are cache-line-size multiples of contiguous bytes.
* The `Allocator` has a maximum memory budget, set at construction
time. This allows us to cap the amount of data each specific
`Allocator` instance is responsible for.
* Upon destruction, the `Allocator` will clean up the storage it's
used, handing it back to the internal allocator used in
sanitizer_common.
Key features of the `Array` type:
* Each segmented array is always backed by an `Allocator`, which is
either user-provided or uses a global allocator.
* When an `Array` grows, it grows by appending a segment that's
fixed-sized. The size of each segment is computed by the number of
elements of type `T` that can fit into cache line multiples.
* An `Array` does not return memory to the `Allocator`, but it can keep
track of the current number of "live" objects it stores.
* When an `Array` is destroyed, it will not return memory to the
`Allocator`. Users should clean up the `Allocator` independently of
the `Array`.
* The `Array` type keeps a freelist of the chunks it's used before, so
that trimming and growing will re-use previously allocated chunks.
These basic data structures are used by the XRay Profiling Mode
implementation to implement efficient and cache-aware storage for data
that's typically read-and-write heavy for tracking latency information.
We're relying on the cache line characteristics of the architecture to
provide us good data isolation and cache friendliness, when we're
performing operations like searching for elements and/or updating data
hosted in these cache lines.
Reviewers: echristo, pelikan, kpw
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D45756
llvm-svn: 331141
2018-04-29 21:46:30 +08:00
|
|
|
xray_buffer_queue.cc
|
|
|
|
xray_fdr_logging.cc)
|
2018-04-11 09:28:25 +08:00
|
|
|
|
|
|
|
set(XRAY_BASIC_MODE_SOURCES
|
[XRay][profiler] Part 1: XRay Allocator and Array Implementations
Summary:
This change is part of the larger XRay Profiling Mode effort.
Here we implement an arena allocator, for fixed sized buffers used in a
segmented array implementation. This change adds the segmented array
data structure, which relies on the allocator to provide and maintain
the storage for the segmented array.
Key features of the `Allocator` type:
* It uses cache-aligned blocks, intended to host the actual data. These
blocks are cache-line-size multiples of contiguous bytes.
* The `Allocator` has a maximum memory budget, set at construction
time. This allows us to cap the amount of data each specific
`Allocator` instance is responsible for.
* Upon destruction, the `Allocator` will clean up the storage it's
used, handing it back to the internal allocator used in
sanitizer_common.
Key features of the `Array` type:
* Each segmented array is always backed by an `Allocator`, which is
either user-provided or uses a global allocator.
* When an `Array` grows, it grows by appending a segment that's
fixed-sized. The size of each segment is computed by the number of
elements of type `T` that can fit into cache line multiples.
* An `Array` does not return memory to the `Allocator`, but it can keep
track of the current number of "live" objects it stores.
* When an `Array` is destroyed, it will not return memory to the
`Allocator`. Users should clean up the `Allocator` independently of
the `Array`.
* The `Array` type keeps a freelist of the chunks it's used before, so
that trimming and growing will re-use previously allocated chunks.
These basic data structures are used by the XRay Profiling Mode
implementation to implement efficient and cache-aware storage for data
that's typically read-and-write heavy for tracking latency information.
We're relying on the cache line characteristics of the architecture to
provide us good data isolation and cache friendliness, when we're
performing operations like searching for elements and/or updating data
hosted in these cache lines.
Reviewers: echristo, pelikan, kpw
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D45756
llvm-svn: 331141
2018-04-29 21:46:30 +08:00
|
|
|
xray_inmemory_log.cc)
|
|
|
|
|
2018-04-11 09:28:25 +08:00
|
|
|
|
2018-04-13 16:33:46 +08:00
|
|
|
# Implementation files for all XRay architectures.
|
[XRay][profiler] Part 1: XRay Allocator and Array Implementations
Summary:
This change is part of the larger XRay Profiling Mode effort.
Here we implement an arena allocator, for fixed sized buffers used in a
segmented array implementation. This change adds the segmented array
data structure, which relies on the allocator to provide and maintain
the storage for the segmented array.
Key features of the `Allocator` type:
* It uses cache-aligned blocks, intended to host the actual data. These
blocks are cache-line-size multiples of contiguous bytes.
* The `Allocator` has a maximum memory budget, set at construction
time. This allows us to cap the amount of data each specific
`Allocator` instance is responsible for.
* Upon destruction, the `Allocator` will clean up the storage it's
used, handing it back to the internal allocator used in
sanitizer_common.
Key features of the `Array` type:
* Each segmented array is always backed by an `Allocator`, which is
either user-provided or uses a global allocator.
* When an `Array` grows, it grows by appending a segment that's
fixed-sized. The size of each segment is computed by the number of
elements of type `T` that can fit into cache line multiples.
* An `Array` does not return memory to the `Allocator`, but it can keep
track of the current number of "live" objects it stores.
* When an `Array` is destroyed, it will not return memory to the
`Allocator`. Users should clean up the `Allocator` independently of
the `Array`.
* The `Array` type keeps a freelist of the chunks it's used before, so
that trimming and growing will re-use previously allocated chunks.
These basic data structures are used by the XRay Profiling Mode
implementation to implement efficient and cache-aware storage for data
that's typically read-and-write heavy for tracking latency information.
We're relying on the cache line characteristics of the architecture to
provide us good data isolation and cache friendliness, when we're
performing operations like searching for elements and/or updating data
hosted in these cache lines.
Reviewers: echristo, pelikan, kpw
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D45756
llvm-svn: 331141
2018-04-29 21:46:30 +08:00
|
|
|
set(x86_64_SOURCES
|
|
|
|
xray_x86_64.cc
|
|
|
|
xray_trampoline_x86_64.S)
|
|
|
|
|
|
|
|
set(arm_SOURCES
|
|
|
|
xray_arm.cc
|
|
|
|
xray_trampoline_arm.S)
|
|
|
|
|
|
|
|
set(armhf_SOURCES
|
|
|
|
${arm_SOURCES})
|
|
|
|
|
|
|
|
set(aarch64_SOURCES
|
|
|
|
xray_AArch64.cc
|
|
|
|
xray_trampoline_AArch64.S)
|
|
|
|
|
|
|
|
set(mips_SOURCES
|
|
|
|
xray_mips.cc
|
|
|
|
xray_trampoline_mips.S)
|
|
|
|
|
|
|
|
set(mipsel_SOURCES
|
|
|
|
xray_mips.cc
|
|
|
|
xray_trampoline_mips.S)
|
|
|
|
|
|
|
|
set(mips64_SOURCES
|
|
|
|
xray_mips64.cc
|
|
|
|
xray_trampoline_mips64.S)
|
|
|
|
|
|
|
|
set(mips64el_SOURCES
|
|
|
|
xray_mips64.cc
|
|
|
|
xray_trampoline_mips64.S)
|
|
|
|
|
2017-02-16 06:40:29 +08:00
|
|
|
set(powerpc64le_SOURCES
|
2017-11-29 06:33:07 +08:00
|
|
|
xray_powerpc64.cc
|
|
|
|
xray_trampoline_powerpc64.cc
|
|
|
|
xray_trampoline_powerpc64_asm.S)
|
2017-02-16 06:40:29 +08:00
|
|
|
|
2018-04-13 16:33:46 +08:00
|
|
|
# Now put it all together...
|
2016-07-21 15:39:55 +08:00
|
|
|
include_directories(..)
|
|
|
|
include_directories(../../include)
|
|
|
|
|
|
|
|
set(XRAY_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
|
|
|
set(XRAY_COMMON_DEFINITIONS XRAY_HAS_EXCEPTIONS=1)
|
2016-11-16 09:01:13 +08:00
|
|
|
append_list_if(
|
|
|
|
COMPILER_RT_HAS_XRAY_COMPILER_FLAG XRAY_SUPPORTED=1 XRAY_COMMON_DEFINITIONS)
|
2017-08-03 08:58:45 +08:00
|
|
|
append_list_if(
|
|
|
|
COMPILER_RT_BUILD_XRAY_NO_PREINIT XRAY_NO_PREINIT XRAY_COMMON_DEFINITIONS)
|
2016-07-21 15:39:55 +08:00
|
|
|
|
2016-08-27 04:52:22 +08:00
|
|
|
add_compiler_rt_component(xray)
|
|
|
|
|
2016-07-21 15:39:55 +08:00
|
|
|
set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
|
2016-11-16 09:01:13 +08:00
|
|
|
RTSanitizerCommon
|
2017-01-12 09:37:35 +08:00
|
|
|
RTSanitizerCommonLibc)
|
2016-07-21 15:39:55 +08:00
|
|
|
|
2017-11-28 19:49:22 +08:00
|
|
|
if (APPLE)
|
|
|
|
set(XRAY_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
|
2017-11-30 03:27:25 +08:00
|
|
|
add_asm_sources(XRAY_ASM_SOURCES xray_trampoline_x86_64.S)
|
2017-11-28 19:49:22 +08:00
|
|
|
|
|
|
|
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
|
|
|
|
add_weak_symbols("xray" WEAK_SYMBOL_LINK_FLAGS)
|
|
|
|
|
|
|
|
add_compiler_rt_object_libraries(RTXray
|
|
|
|
OS ${XRAY_SUPPORTED_OS}
|
|
|
|
ARCHS ${XRAY_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${x86_64_SOURCES}
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS})
|
2018-04-11 09:28:25 +08:00
|
|
|
add_compiler_rt_object_libraries(RTXrayFDR
|
|
|
|
OS ${XRAY_SUPPORTED_OS}
|
|
|
|
ARCHS ${XRAY_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${XRAY_FDR_MODE_SOURCES}
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(RTXrayBASIC
|
|
|
|
OS ${XRAY_SUPPORTED_OS}
|
|
|
|
ARCHS ${XRAY_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${XRAY_BASIC_MODE_SOURCES}
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS})
|
2017-11-28 19:49:22 +08:00
|
|
|
|
|
|
|
# We only support running on osx for now.
|
|
|
|
add_compiler_rt_runtime(clang_rt.xray
|
|
|
|
STATIC
|
|
|
|
OS ${XRAY_SUPPORTED_OS}
|
|
|
|
ARCHS ${XRAY_SUPPORTED_ARCH}
|
|
|
|
OBJECT_LIBS RTXray
|
|
|
|
RTSanitizerCommon
|
|
|
|
RTSanitizerCommonLibc
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS}
|
|
|
|
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
|
|
|
|
LINK_LIBS ${XRAY_LINK_LIBS}
|
|
|
|
PARENT_TARGET xray)
|
2018-04-11 09:28:25 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.xray-fdr
|
|
|
|
STATIC
|
|
|
|
OS ${XRAY_SUPPORTED_OS}
|
|
|
|
ARCHS ${XRAY_SUPPORTED_ARCH}
|
|
|
|
OBJECT_LIBS RTXrayFDR
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS}
|
|
|
|
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
|
|
|
|
LINK_LIBS ${XRAY_LINK_LIBS}
|
|
|
|
PARENT_TARGET xray)
|
|
|
|
add_compiler_rt_runtime(clang_rt.xray-basic
|
|
|
|
STATIC
|
|
|
|
OS ${XRAY_SUPPORTED_OS}
|
|
|
|
ARCHS ${XRAY_SUPPORTED_ARCH}
|
|
|
|
OBJECT_LIBS RTXrayBASIC
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS}
|
|
|
|
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
|
|
|
|
LINK_LIBS ${XRAY_LINK_LIBS}
|
|
|
|
PARENT_TARGET xray)
|
2018-04-13 16:33:46 +08:00
|
|
|
else() # not Apple
|
|
|
|
foreach(arch ${XRAY_SUPPORTED_ARCH})
|
|
|
|
if(NOT CAN_TARGET_${arch})
|
|
|
|
continue()
|
|
|
|
endif()
|
2017-11-28 19:49:22 +08:00
|
|
|
add_compiler_rt_object_libraries(RTXray
|
2017-12-06 22:03:41 +08:00
|
|
|
ARCHS ${arch}
|
2018-04-11 09:28:25 +08:00
|
|
|
SOURCES ${XRAY_SOURCES} ${${arch}_SOURCES} CFLAGS ${XRAY_CFLAGS}
|
2017-11-28 19:49:22 +08:00
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS})
|
2018-04-11 09:28:25 +08:00
|
|
|
add_compiler_rt_object_libraries(RTXrayFDR
|
|
|
|
ARCHS ${arch}
|
|
|
|
SOURCES ${XRAY_FDR_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(RTXrayBASIC
|
|
|
|
ARCHS ${arch}
|
|
|
|
SOURCES ${XRAY_BASIC_MODE_SOURCES} CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS})
|
|
|
|
|
2018-04-13 16:33:46 +08:00
|
|
|
# Common XRay archive for instrumented binaries.
|
2016-12-06 14:24:08 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.xray
|
|
|
|
STATIC
|
|
|
|
ARCHS ${arch}
|
2017-10-24 01:13:24 +08:00
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
2016-12-06 14:24:08 +08:00
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS}
|
2018-04-11 09:28:25 +08:00
|
|
|
OBJECT_LIBS ${XRAY_COMMON_RUNTIME_OBJECT_LIBS} RTXray
|
|
|
|
PARENT_TARGET xray)
|
2018-04-13 16:33:46 +08:00
|
|
|
# FDR mode runtime archive (addon for clang_rt.xray)
|
|
|
|
add_compiler_rt_runtime(clang_rt.xray-fdr
|
|
|
|
STATIC
|
|
|
|
ARCHS ${arch}
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS}
|
|
|
|
OBJECT_LIBS RTXrayFDR
|
|
|
|
PARENT_TARGET xray)
|
|
|
|
# Basic mode runtime archive (addon for clang_rt.xray)
|
|
|
|
add_compiler_rt_runtime(clang_rt.xray-basic
|
|
|
|
STATIC
|
|
|
|
ARCHS ${arch}
|
|
|
|
CFLAGS ${XRAY_CFLAGS}
|
|
|
|
DEFS ${XRAY_COMMON_DEFINITIONS}
|
|
|
|
OBJECT_LIBS RTXrayBASIC
|
|
|
|
PARENT_TARGET xray)
|
|
|
|
endforeach()
|
|
|
|
endif() # not Apple
|
2016-12-06 14:24:08 +08:00
|
|
|
|
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|