From 131638a7be1649928abcf3aabc249e827f957733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sat, 4 Nov 2023 00:21:32 +0100 Subject: [PATCH] HINTED & OPTIMISTIC CONTAINER INFO --- nano/node/scheduler/component.cpp | 2 ++ nano/node/scheduler/hinted.cpp | 15 +++++++++++++++ nano/node/scheduler/hinted.hpp | 2 ++ nano/node/scheduler/optimistic.cpp | 9 +++++++++ nano/node/scheduler/optimistic.hpp | 2 ++ 5 files changed, 30 insertions(+) diff --git a/nano/node/scheduler/component.cpp b/nano/node/scheduler/component.cpp index 983baee7c2..1ed61dbf68 100644 --- a/nano/node/scheduler/component.cpp +++ b/nano/node/scheduler/component.cpp @@ -42,5 +42,7 @@ nano::experimental::container_info nano::scheduler::component::collect_container nano::experimental::container_info info; info.add ("manual", manual.collect_container_info ()); info.add ("priority", priority.collect_container_info ()); + info.add ("optimistic", optimistic.collect_container_info ()); + info.add ("hinted", hinted.collect_container_info ()); return info; } diff --git a/nano/node/scheduler/hinted.cpp b/nano/node/scheduler/hinted.cpp index 54f5bdf7b8..e438444ae3 100644 --- a/nano/node/scheduler/hinted.cpp +++ b/nano/node/scheduler/hinted.cpp @@ -163,10 +163,14 @@ void nano::scheduler::hinted::run () if (!stopped) { + lock.unlock (); + if (predicate ()) { run_iterative (); } + + lock.lock (); } } } @@ -185,6 +189,8 @@ nano::uint128_t nano::scheduler::hinted::final_tally_threshold () const bool nano::scheduler::hinted::cooldown (const nano::block_hash & hash) { + nano::lock_guard lock{ mutex }; + auto const now = std::chrono::steady_clock::now (); // Check if the hash is still in the cooldown period using the hashed index @@ -211,6 +217,15 @@ bool nano::scheduler::hinted::cooldown (const nano::block_hash & hash) return false; // No need to cooldown } +nano::experimental::container_info nano::scheduler::hinted::collect_container_info () const +{ + nano::unique_lock lock{ mutex }; + + nano::experimental::container_info info; + info.put ("cooldowns", cooldowns_m); + return info; +} + /* * hinted_config */ diff --git a/nano/node/scheduler/hinted.hpp b/nano/node/scheduler/hinted.hpp index 590697c39f..8b8ec82aee 100644 --- a/nano/node/scheduler/hinted.hpp +++ b/nano/node/scheduler/hinted.hpp @@ -58,6 +58,8 @@ class hinted final */ void notify (); + nano::experimental::container_info collect_container_info () const; + private: bool predicate () const; void run (); diff --git a/nano/node/scheduler/optimistic.cpp b/nano/node/scheduler/optimistic.cpp index b47ddb9fdf..2ef41a2e05 100644 --- a/nano/node/scheduler/optimistic.cpp +++ b/nano/node/scheduler/optimistic.cpp @@ -161,6 +161,15 @@ void nano::scheduler::optimistic::run_one (store::transaction const & transactio } } +nano::experimental::container_info nano::scheduler::optimistic::collect_container_info () const +{ + nano::unique_lock lock{ mutex }; + + nano::experimental::container_info info; + info.put ("candidates", candidates); + return info; +} + /* * optimistic_scheduler_config */ diff --git a/nano/node/scheduler/optimistic.hpp b/nano/node/scheduler/optimistic.hpp index 627b74d621..fc31c8eaf3 100644 --- a/nano/node/scheduler/optimistic.hpp +++ b/nano/node/scheduler/optimistic.hpp @@ -66,6 +66,8 @@ class optimistic final */ void notify (); + nano::experimental::container_info collect_container_info () const; + private: bool activate_predicate (nano::account_info const &, nano::confirmation_height_info const &) const;