mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This seems to more than fix a performance regression that we detected on a metadata-allocation microbenchmark. A few months ago, I improved the metadata cache representation and changed the metadata allocation scheme to primarily use malloc. Previously, we'd been using malloc in the concurrent tree data structure but a per-cache slab allocator for the metadata itself. At the time, I was concerned about the overhead of per-cache allocators, since many metadata patterns see only a small number of instantiations. That's still an important factor, so in the new scheme we're using a global allocator; but instead of using malloc for individual allocations, we're using a slab allocator, which should have better peak, single-thread performance, at the cost of not easily supporting deallocation. Deallocation is only used for metadata when there's contention on the cache, and specifically only when there's contention for the same key, so leaking a little isn't the worst thing in the world. The initial slab is a 64K globally-allocated buffer. Successive slabs are 16K and allocated with malloc. rdar://28189496
76 lines
2.7 KiB
CMake
76 lines
2.7 KiB
CMake
|
|
include(AddSwift)
|
|
|
|
add_custom_target(SwiftUnitTests)
|
|
|
|
set_target_properties(SwiftUnitTests PROPERTIES FOLDER "Tests")
|
|
|
|
function(add_swift_unittest test_dirname)
|
|
# *NOTE* Even though "add_unittest" does not have llvm in its name, it is a
|
|
# function defined by AddLLVM.cmake.
|
|
add_unittest(SwiftUnitTests ${test_dirname} ${ARGN})
|
|
|
|
# TODO: _add_variant_c_compile_link_flags and these tests should share some
|
|
# sort of logic.
|
|
#
|
|
# *NOTE* The unittests are never built for the target, so we always enable LTO
|
|
# *if we are asked to.
|
|
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
|
|
if (_lto_flag_out)
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY COMPILE_FLAGS " ${_lto_flag_out} ")
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY LINK_FLAGS " ${_lto_flag_out} ")
|
|
endif()
|
|
|
|
if(SWIFT_BUILT_STANDALONE AND NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
|
# Replace target references with full paths, so that we use LLVM's
|
|
# build configuration rather than Swift's.
|
|
get_target_property(libnames ${test_dirname} LINK_LIBRARIES)
|
|
|
|
set(new_libnames)
|
|
foreach(dep ${libnames})
|
|
if("${dep}" MATCHES "^(LLVM|Clang|gtest)")
|
|
list(APPEND new_libnames "${LLVM_LIBRARY_OUTPUT_INTDIR}/lib${dep}.a")
|
|
else()
|
|
list(APPEND new_libnames "${dep}")
|
|
endif()
|
|
endforeach()
|
|
|
|
set_property(TARGET ${test_dirname} PROPERTY LINK_LIBRARIES ${new_libnames})
|
|
swift_common_llvm_config(${test_dirname} support)
|
|
endif()
|
|
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx")
|
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -latomic")
|
|
endif()
|
|
|
|
if(SWIFT_ENABLE_GOLD_LINKER AND
|
|
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -fuse-ld=gold")
|
|
endif()
|
|
if(SWIFT_ENABLE_LLD_LINKER)
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -fuse-ld=lld")
|
|
endif()
|
|
|
|
if(SWIFT_ANALYZE_CODE_COVERAGE)
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
|
|
endif()
|
|
|
|
if(SWIFT_RUNTIME_USE_SANITIZERS)
|
|
if("Thread" IN_LIST SWIFT_RUNTIME_USE_SANITIZERS)
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY COMPILE_FLAGS
|
|
" -fsanitize=thread")
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -fsanitize=thread")
|
|
endif()
|
|
endif()
|
|
endfunction()
|
|
|
|
|