diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c1753320..3d696dae0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,7 +68,7 @@ jobs: # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: | - cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -GNinja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -GNinja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -L cd ${{github.workspace}}/build && pwd du -hcs _deps/ - name: Build & Test diff --git a/CMakeLists.txt b/CMakeLists.txt index dbd4b4daa..8e33b2895 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,8 @@ find_package(OpenSSL) include(third_party) include(internal) +set(USE_FB2 ON CACHE BOOL "") + include_directories(src) include_directories(helio) diff --git a/helio b/helio index 7927a743f..848f6f266 160000 --- a/helio +++ b/helio @@ -1 +1 @@ -Subproject commit 7927a743f3452c0fa645a1567c3d4202fd4ab9ef +Subproject commit 848f6f266226c46bee99a36efd7bcfd7f1ffaf0e diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a79e576f7..33d7fd57d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -67,6 +67,8 @@ endif(ENABLE_GIT_VERSION) # the output file resides in the build directory. configure_file(server/version.cc.in "${CMAKE_CURRENT_SOURCE_DIR}/server/version.cc" @ONLY) +add_definitions(-DUSE_FB2) + add_subdirectory(redis) add_subdirectory(core) add_subdirectory(facade) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 765cb4c63..50d95479f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -4,7 +4,7 @@ add_library(dfly_core compact_object.cc dragonfly_core.cc extent_tree.cc string_set.cc string_map.cc detail/bitpacking.cc) cxx_link(dfly_core base absl::flat_hash_map absl::str_format redis_lib TRDP::lua lua_modules - Boost::fiber TRDP::jsoncons OpenSSL::Crypto) + fibers2 TRDP::jsoncons OpenSSL::Crypto) add_executable(dash_bench dash_bench.cc) cxx_link(dash_bench dfly_core) diff --git a/src/facade/CMakeLists.txt b/src/facade/CMakeLists.txt index 549fc5503..92ace2f8f 100644 --- a/src/facade/CMakeLists.txt +++ b/src/facade/CMakeLists.txt @@ -7,7 +7,7 @@ if (DF_USE_SSL) target_compile_definitions(dfly_facade PRIVATE DFLY_USE_SSL) endif() -cxx_link(dfly_facade base uring_fiber_lib fibers_ext strings_lib http_server_lib +cxx_link(dfly_facade base strings_lib http_server_lib fibers2 ${TLS_LIB} TRDP::mimalloc TRDP::dconv) add_library(facade_test facade_test.cc) diff --git a/src/facade/ok_main.cc b/src/facade/ok_main.cc index 44360a474..7377bc68b 100644 --- a/src/facade/ok_main.cc +++ b/src/facade/ok_main.cc @@ -7,7 +7,7 @@ #include "facade/dragonfly_listener.h" #include "facade/service_interface.h" #include "util/accept_server.h" -#include "util/uring/uring_pool.h" +#include "util/fibers/pool.h" ABSL_FLAG(uint32_t, port, 6379, "server port"); @@ -59,13 +59,13 @@ int main(int argc, char* argv[]) { CHECK_GT(GetFlag(FLAGS_port), 0u); - uring::UringPool pp{1024}; - pp.Run(); + unique_ptr pp(fb2::Pool::IOUring(1024)); + pp->Run(); - AcceptServer acceptor(&pp); - facade::RunEngine(&pp, &acceptor); + AcceptServer acceptor(pp.get()); + facade::RunEngine(pp.get(), &acceptor); - pp.Stop(); + pp->Stop(); return 0; } diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index f742a3f9d..7c49b1385 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(dragonfly dfly_main.cc) -cxx_link(dragonfly base dragonfly_lib epoll_fiber_lib) +cxx_link(dragonfly base dragonfly_lib) if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_BUILD_TYPE STREQUAL "Release") # Add core2 only to this file, thus avoiding instructions in this object file that @@ -12,7 +12,7 @@ add_library(dfly_transaction db_slice.cc malloc_stats.cc engine_shard_set.cc blo common.cc io_mgr.cc journal/journal.cc journal/journal_slice.cc server_state.cc table.cc tiered_storage.cc top_keys.cc transaction.cc) -cxx_link(dfly_transaction uring_fiber_lib dfly_core strings_lib) +cxx_link(dfly_transaction dfly_core strings_lib) add_library(dragonfly_lib channel_store.cc command_registry.cc config_flags.cc conn_context.cc debugcmd.cc dflycmd.cc @@ -28,7 +28,7 @@ cxx_link(dragonfly_lib dfly_transaction dfly_facade redis_lib strings_lib html_l absl::random_random TRDP::jsoncons zstd TRDP::lz4) add_library(dfly_test_lib test_utils.cc) -cxx_link(dfly_test_lib dragonfly_lib epoll_fiber_lib facade_test gtest_main_ext) +cxx_link(dfly_test_lib dragonfly_lib facade_test gtest_main_ext) cxx_test(dragonfly_test dfly_test_lib LABELS DFLY) cxx_test(multi_test dfly_test_lib LABELS DFLY) diff --git a/src/server/blocking_controller_test.cc b/src/server/blocking_controller_test.cc index 382899a04..67836cfd5 100644 --- a/src/server/blocking_controller_test.cc +++ b/src/server/blocking_controller_test.cc @@ -11,7 +11,7 @@ #include "server/engine_shard_set.h" #include "server/server_state.h" #include "server/transaction.h" -#include "util/uring/uring_pool.h" +#include "util/fibers/pool.h" namespace dfly { @@ -37,7 +37,7 @@ class BlockingControllerTest : public Test { constexpr size_t kNumThreads = 3; void BlockingControllerTest::SetUp() { - pp_.reset(new uring::UringPool(16, kNumThreads)); + pp_.reset(fb2::Pool::IOUring(16, kNumThreads)); pp_->Run(); pp_->Await([](unsigned index, ProactorBase* p) { ServerState::Init(index); }); diff --git a/src/server/dfly_main.cc b/src/server/dfly_main.cc index 3b005b910..80649a73f 100644 --- a/src/server/dfly_main.cc +++ b/src/server/dfly_main.cc @@ -30,9 +30,8 @@ #include "server/version.h" #include "strings/human_readable.h" #include "util/accept_server.h" -#include "util/epoll/epoll_pool.h" +#include "util/fibers/pool.h" #include "util/http/http_client.h" -#include "util/uring/uring_pool.h" #include "util/varz.h" #define STRING_PP_NX(A) #A @@ -527,9 +526,9 @@ Usage: dragonfly [FLAGS] bool use_epoll = ShouldUseEpollAPI(kver); if (use_epoll) { - pool.reset(new epoll::EpollPool); + pool.reset(fb2::Pool::Epoll()); } else { - pool.reset(new uring::UringPool(1024)); // 1024 - iouring queue size. + pool.reset(fb2::Pool::IOUring(1024)); // 1024 - iouring queue size. } pool->Run(); diff --git a/src/server/io_mgr.cc b/src/server/io_mgr.cc index 61a018bf7..becafe567 100644 --- a/src/server/io_mgr.cc +++ b/src/server/io_mgr.cc @@ -86,12 +86,12 @@ error_code IoMgr::GrowAsync(size_t len, GrowCb cb) { Proactor* proactor = (Proactor*)ProactorBase::me(); SubmitEntry entry = proactor->GetSubmitEntry( - [this, cb = move(cb)](Proactor::IoResult res, uint32_t, int64_t arg) { + [this, len, cb = move(cb)](auto*, Proactor::IoResult res, uint32_t) { this->flags.grow_progress = 0; - sz_ += (res == 0 ? arg : 0); + sz_ += (res == 0 ? len : 0); cb(res); }, - len); + 0); entry.PrepFallocate(backing_file_->fd(), 0, sz_, len); flags.grow_progress = 1; @@ -105,9 +105,7 @@ error_code IoMgr::WriteAsync(size_t offset, string_view blob, WriteCb cb) { Proactor* proactor = (Proactor*)ProactorBase::me(); - auto ring_cb = [cb = move(cb)](Proactor::IoResult res, uint32_t flags, int64_t payload) { - cb(res); - }; + auto ring_cb = [cb = move(cb)](auto*, Proactor::IoResult res, uint32_t flags) { cb(res); }; SubmitEntry se = proactor->GetSubmitEntry(move(ring_cb), 0); se.PrepWrite(backing_file_->fd(), blob.data(), blob.size(), offset); diff --git a/src/server/io_utils.h b/src/server/io_utils.h index a3e74468c..9e5de763c 100644 --- a/src/server/io_utils.h +++ b/src/server/io_utils.h @@ -3,6 +3,7 @@ // #include "base/io_buf.h" +#include "core/fibers.h" #include "io/io.h" #include "server/common.h" diff --git a/src/server/server_family.cc b/src/server/server_family.cc index 6fdfda859..9aaf0348b 100644 --- a/src/server/server_family.cc +++ b/src/server/server_family.cc @@ -1453,7 +1453,7 @@ void ServerFamily::Info(CmdArgList args, ConnectionContext* cntx) { Metrics m = GetMetrics(); if (should_enter("SERVER")) { - ProactorBase::ProactorKind kind = ProactorBase::me()->GetKind(); + auto kind = ProactorBase::me()->GetKind(); const char* multiplex_api = (kind == ProactorBase::IOURING) ? "iouring" : "epoll"; ADD_HEADER("# Server"); diff --git a/src/server/test_utils.cc b/src/server/test_utils.cc index 4dc1bff51..beee86980 100644 --- a/src/server/test_utils.cc +++ b/src/server/test_utils.cc @@ -16,8 +16,7 @@ extern "C" { #include "base/logging.h" #include "base/stl_util.h" #include "facade/dragonfly_connection.h" -#include "util/epoll/epoll_pool.h" -#include "util/uring/uring_pool.h" +#include "util/fibers/pool.h" using namespace std; @@ -138,9 +137,9 @@ void BaseFamilyTest::SetUpTestSuite() { void BaseFamilyTest::SetUp() { if (absl::GetFlag(FLAGS_force_epoll)) { - pp_.reset(new epoll::EpollPool(num_threads_)); + pp_.reset(fb2::Pool::Epoll(num_threads_)); } else { - pp_.reset(new uring::UringPool(16, num_threads_)); + pp_.reset(fb2::Pool::IOUring(16, num_threads_)); } pp_->Run(); service_.reset(new Service{pp_.get()});