From b6fd402a3c0e83917a0befe0f6ce4606ce024cfc Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 24 Nov 2021 12:12:22 -0800 Subject: [PATCH] Add option to use boost or libcoro By default, use boost everywhere except windows and linux x86 (for performance reasons) --- cmake/FDBComponents.cmake | 15 +++++++++++++++ fdbrpc/CMakeLists.txt | 23 +++++++++++++++++++---- fdbserver/CMakeLists.txt | 3 +-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/cmake/FDBComponents.cmake b/cmake/FDBComponents.cmake index 6609709222..87cb8ebfd5 100644 --- a/cmake/FDBComponents.cmake +++ b/cmake/FDBComponents.cmake @@ -202,6 +202,21 @@ else() target_include_directories(toml11_target SYSTEM INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/toml11/include) endif() +################################################################################ +# Coroutine implementation +################################################################################ + +set(DEFAULT_COROUTINE_IMPL boost) +if(WIN32) + # boost coroutine not available in windows build environment for now. + set(DEFAULT_COROUTINE_IMPL libcoro) +elseif(NOT APPLE AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^x86") + # revert to libcoro for x86 linux while we investigate a performance regression + set(DEFAULT_COROUTINE_IMPL libcoro) +endif() + +set(COROUTINE_IMPL ${DEFAULT_COROUTINE_IMPL} CACHE STRING "Which coroutine implementation to use. Options are boost and libcoro") + ################################################################################ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages) diff --git a/fdbrpc/CMakeLists.txt b/fdbrpc/CMakeLists.txt index ddc1076359..2a7c2cd183 100644 --- a/fdbrpc/CMakeLists.txt +++ b/fdbrpc/CMakeLists.txt @@ -86,8 +86,23 @@ if(COMPILE_EIO) target_link_libraries(fdbrpc PRIVATE eio) target_link_libraries(fdbrpc_sampling PRIVATE eio) endif() -if(WIN32) - add_library(coro STATIC libcoroutine/Common.c libcoroutine/Coro.c) - target_link_libraries(fdbrpc PRIVATE coro) - target_link_libraries(fdbrpc_sampling PRIVATE coro) + +set(CORO_SRCS libcoroutine/Common.c libcoroutine/Coro.c) +if(APPLE) + list(APPEND CORO_SRCS libcoroutine/asm.S) endif() +if(NOT WIN32) + list(APPEND CORO_SRCS libcoroutine/context.c) +endif() +add_library(coro STATIC ${CORO_SRCS}) +if(WIN32) + target_compile_definitions(coro PRIVATE USE_FIBERS) +else() + target_compile_definitions(coro PRIVATE USE_UCONTEXT) + target_compile_options(coro BEFORE PRIVATE -w) # disable warnings for third party +endif() +if(USE_VALGRIND) + target_link_libraries(coro PUBLIC Valgrind) +endif() +target_link_libraries(fdbrpc PRIVATE coro) +target_link_libraries(fdbrpc_sampling PRIVATE coro) diff --git a/fdbserver/CMakeLists.txt b/fdbserver/CMakeLists.txt index c1ed1d01ae..79ed01cda0 100644 --- a/fdbserver/CMakeLists.txt +++ b/fdbserver/CMakeLists.txt @@ -270,8 +270,7 @@ set(FDBSERVER_SRCS workloads/WriteTagThrottling.actor.cpp ) -# ugly hack to make Windows work for now -if(WIN32) +if(${COROUTINE_IMPL} STREQUAL libcoro) list(APPEND FDBSERVER_SRCS CoroFlowCoro.actor.cpp) else() list(APPEND FDBSERVER_SRCS CoroFlow.actor.cpp)