diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ae550dbe..6172010c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ if(CCACHE_FOUND) endif(CCACHE_FOUND) option(WITH_JEMALLOC "build with JeMalloc" OFF) +option(WITH_LIBURING "build with liburing" ON) option(WITH_SNAPPY "build with SNAPPY" OFF) option(WITH_LZ4 "build with lz4" OFF) option(WITH_ZLIB "build with zlib" OFF) @@ -338,6 +339,22 @@ if (NOT BUILTIN_ATOMIC) endif() endif() +if (WITH_LIBURING) + set(CMAKE_REQUIRED_FLAGS "-luring") + CHECK_CXX_SOURCE_COMPILES(" +#include +int main() { + struct io_uring ring; + io_uring_queue_init(1, &ring, 0); + return 0; +} +" HAS_LIBURING) + if (HAS_LIBURING) + add_definitions(-DROCKSDB_IOURING_PRESENT) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -luring") + endif() +endif() + # Reset the required flags set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) diff --git a/HISTORY.md b/HISTORY.md index fc62add11..8b9f4c32e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -36,6 +36,9 @@ ### Default Option Change * When options.arena_block_size <= 0 (default value 0), still use writer_buffer_size / 8 but cap to 1MB. Too large alloation size might not be friendly to allocator and might cause performance issues in extreme cases. +### Build +* By default, try to build with liburing. For make, if ROCKSDB_USE_IO_URING is not set, treat as enable, which means RocksDB will try to build with liburing. Users can disable it with ROCKSDB_USE_IO_URING=0. For cmake, add WITH_LIBURING to control it, with default on. + ## 6.20.0 (2021-04-16) ### Behavior Changes * `ColumnFamilyOptions::sample_for_compression` now takes effect for creation of all block-based tables. Previously it only took effect for block-based tables created by flush. diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index b63790578..72d8cea12 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -175,7 +175,10 @@ case "$TARGET_OS" in PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic" fi PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt -ldl" - if test $ROCKSDB_USE_IO_URING; then + if test -z "$ROCKSDB_USE_IO_URING"; then + ROCKSDB_USE_IO_URING=1 + fi + if test "$ROCKSDB_USE_IO_URING" -ne 0; then # check for liburing $CXX $PLATFORM_CXXFLAGS -x c++ - -luring -o /dev/null 2>/dev/null <