From 1c2774eea7080216a03feb07d21127bd0d37ac75 Mon Sep 17 00:00:00 2001 From: Yaming Kuang Date: Fri, 22 Sep 2023 17:26:22 -0700 Subject: [PATCH] github issue #159: Setup CP periodic timer and dirty buf exceed callback --- conanfile.py | 2 +- src/include/homestore/checkpoint/cp_mgr.hpp | 3 ++- src/lib/checkpoint/cp_mgr.cpp | 14 +++++++++++++- src/lib/common/homestore_config.fbs | 4 ++-- src/lib/common/resource_mgr.hpp | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index 19d52eb90..83e03ce9d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "4.4.0" + version = "4.4.1" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/include/homestore/checkpoint/cp_mgr.hpp b/src/include/homestore/checkpoint/cp_mgr.hpp index 322f3411e..bd3714cc1 100644 --- a/src/include/homestore/checkpoint/cp_mgr.hpp +++ b/src/include/homestore/checkpoint/cp_mgr.hpp @@ -163,6 +163,7 @@ class CPManager { std::unique_ptr< CPWatchdog > m_wd_cp; superblk< cp_mgr_super_block > m_sb; std::vector< iomgr::io_fiber_t > m_cp_io_fibers; + iomgr::timer_handle_t m_cp_timer_hdl; public: CPManager(); @@ -206,7 +207,7 @@ class CPManager { /// @brief Trigger a checkpoint flush on all subsystems registered. There is only 1 checkpoint per checkpoint /// manager. Checkpoint flush will wait for cp to exited all critical io sections. - /// @param force : Do we need to force queue the checkpoint flush, in case previous checkpoint is been flushed + /// @param force : Do we need to force queue the checkpoint flush, in case previous checkpoint is being flushed folly::Future< bool > trigger_cp_flush(bool force = false); const std::array< std::unique_ptr< CPCallbacks >, (size_t)cp_consumer_t::SENTINEL >& consumer_list() const { diff --git a/src/lib/checkpoint/cp_mgr.cpp b/src/lib/checkpoint/cp_mgr.cpp index 82669645b..55e43000e 100644 --- a/src/lib/checkpoint/cp_mgr.cpp +++ b/src/lib/checkpoint/cp_mgr.cpp @@ -18,9 +18,10 @@ #include #include #include - +#include #include "common/homestore_assert.hpp" #include "common/homestore_config.hpp" +#include "common/resource_mgr.hpp" #include "cp.hpp" namespace homestore { @@ -35,6 +36,9 @@ CPManager::CPManager() : [this](meta_blk* mblk, sisl::byte_view buf, size_t size) { on_meta_blk_found(std::move(buf), (void*)mblk); }, nullptr); + resource_mgr().register_dirty_buf_exceed_cb( + [this]([[maybe_unused]] int64_t dirty_buf_count) { this->trigger_cp_flush(false /* false */); }); + start_cp_thread(); } @@ -46,6 +50,11 @@ void CPManager::start(bool first_time_boot) { create_first_cp(); m_sb.write(); } + + LOGINFO("cp timer is set to {} usec", HS_DYNAMIC_CONFIG(generic.cp_timer_us)); + m_cp_timer_hdl = iomanager.schedule_global_timer( + HS_DYNAMIC_CONFIG(generic.cp_timer_us) * 1000, true, nullptr /*cookie*/, iomgr::reactor_regex::all_worker, + [this](void*) { trigger_cp_flush(false /* false */); }, true /* wait_to_schedule */); } void CPManager::on_meta_blk_found(const sisl::byte_view& buf, void* meta_cookie) { @@ -70,6 +79,9 @@ void CPManager::shutdown() { m_wd_cp->stop(); m_wd_cp.reset(); } + + iomanager.cancel_timer(m_cp_timer_hdl, true); + m_cp_timer_hdl = iomgr::null_timer_handle; } void CPManager::register_consumer(cp_consumer_t consumer_id, std::unique_ptr< CPCallbacks > callbacks) { diff --git a/src/lib/common/homestore_config.fbs b/src/lib/common/homestore_config.fbs index 00b62d59d..e299ee8f9 100644 --- a/src/lib/common/homestore_config.fbs +++ b/src/lib/common/homestore_config.fbs @@ -116,8 +116,8 @@ table LogStore { } table Generic { - // blk alloc cp timer in us - blkalloc_cp_timer_us: uint64 = 60000000 (hotswap); + // cp timer in us + cp_timer_us: uint64 = 60000000 (hotswap); // writeback cache flush threads cache_flush_threads : int32 = 1; diff --git a/src/lib/common/resource_mgr.hpp b/src/lib/common/resource_mgr.hpp index f475aef96..47424d36f 100644 --- a/src/lib/common/resource_mgr.hpp +++ b/src/lib/common/resource_mgr.hpp @@ -39,7 +39,7 @@ class RsrcMgrMetrics : public sisl::MetricsGroup { ~RsrcMgrMetrics() { deregister_me_from_farm(); } }; -typedef std::function< void(int64_t) > exceed_limit_cb_t; +typedef std::function< void(int64_t /* dirty_buf_cnt */) > exceed_limit_cb_t; const uint32_t max_qd_multiplier = 32; class ResourceMgr {