From 6ceacc14ae3cc115939028f75cf53c90d5e057a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Wed, 8 Nov 2023 00:14:36 +0100 Subject: [PATCH] Ignore AEC vacancy notification for hinted scheduler --- nano/core_test/toml.cpp | 2 -- nano/node/scheduler/hinted.cpp | 15 ++------------- nano/node/scheduler/hinted.hpp | 1 - 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/nano/core_test/toml.cpp b/nano/core_test/toml.cpp index 744e70acd8..8adb17d82e 100644 --- a/nano/core_test/toml.cpp +++ b/nano/core_test/toml.cpp @@ -275,7 +275,6 @@ TEST (toml, daemon_config_deserialize_defaults) ASSERT_EQ (conf.node.hinted_scheduler.hinting_threshold_percent, defaults.node.hinted_scheduler.hinting_threshold_percent); ASSERT_EQ (conf.node.hinted_scheduler.check_interval.count (), defaults.node.hinted_scheduler.check_interval.count ()); ASSERT_EQ (conf.node.hinted_scheduler.block_cooldown.count (), defaults.node.hinted_scheduler.block_cooldown.count ()); - ASSERT_EQ (conf.node.hinted_scheduler.vacancy_threshold_percent, defaults.node.hinted_scheduler.vacancy_threshold_percent); ASSERT_EQ (conf.node.vote_cache.max_size, defaults.node.vote_cache.max_size); ASSERT_EQ (conf.node.vote_cache.max_voters, defaults.node.vote_cache.max_voters); @@ -722,7 +721,6 @@ TEST (toml, daemon_config_deserialize_no_defaults) ASSERT_NE (conf.node.hinted_scheduler.hinting_threshold_percent, defaults.node.hinted_scheduler.hinting_threshold_percent); ASSERT_NE (conf.node.hinted_scheduler.check_interval.count (), defaults.node.hinted_scheduler.check_interval.count ()); ASSERT_NE (conf.node.hinted_scheduler.block_cooldown.count (), defaults.node.hinted_scheduler.block_cooldown.count ()); - ASSERT_NE (conf.node.hinted_scheduler.vacancy_threshold_percent, defaults.node.hinted_scheduler.vacancy_threshold_percent); ASSERT_NE (conf.node.vote_cache.max_size, defaults.node.vote_cache.max_size); ASSERT_NE (conf.node.vote_cache.max_voters, defaults.node.vote_cache.max_voters); diff --git a/nano/node/scheduler/hinted.cpp b/nano/node/scheduler/hinted.cpp index 6bbaff7de9..833e59f929 100644 --- a/nano/node/scheduler/hinted.cpp +++ b/nano/node/scheduler/hinted.cpp @@ -45,12 +45,8 @@ void nano::scheduler::hinted::stop () void nano::scheduler::hinted::notify () { - // Avoid notifying when there is very little space inside AEC - auto const limit = active.limit (nano::election_behavior::hinted); - if (active.vacancy (nano::election_behavior::hinted) >= (limit * config.vacancy_threshold_percent / 100)) - { - condition.notify_all (); - } + // Ignore vacancy notifications, since they are causing (expensive) vote cache iteration to run too often + // TODO: Research a better way to handle this } bool nano::scheduler::hinted::predicate () const @@ -230,7 +226,6 @@ nano::error nano::scheduler::hinted_config::serialize (nano::tomlconfig & toml) toml.put ("hinting_threshold", hinting_threshold_percent, "Percentage of online weight needed to start a hinted election. \ntype:uint32,[0,100]"); toml.put ("check_interval", check_interval.count (), "Interval between scans of the vote cache for possible hinted elections. \ntype:milliseconds"); toml.put ("block_cooldown", block_cooldown.count (), "Cooldown period for blocks that failed to start an election. \ntype:milliseconds"); - toml.put ("vacancy_threshold", vacancy_threshold_percent, "Percentage of available space in the active elections container needed to trigger a scan for hinted elections (before the check interval elapses). \ntype:uint32,[0,100]"); return toml.get_error (); } @@ -247,16 +242,10 @@ nano::error nano::scheduler::hinted_config::deserialize (nano::tomlconfig & toml toml.get ("block_cooldown", block_cooldown_l); block_cooldown = std::chrono::milliseconds{ block_cooldown_l }; - toml.get ("vacancy_threshold", vacancy_threshold_percent); - if (hinting_threshold_percent > 100) { toml.get_error ().set ("hinting_threshold must be a number between 0 and 100"); } - if (vacancy_threshold_percent > 100) - { - toml.get_error ().set ("vacancy_threshold must be a number between 0 and 100"); - } return toml.get_error (); } \ No newline at end of file diff --git a/nano/node/scheduler/hinted.hpp b/nano/node/scheduler/hinted.hpp index a80bb68c05..f907e21175 100644 --- a/nano/node/scheduler/hinted.hpp +++ b/nano/node/scheduler/hinted.hpp @@ -39,7 +39,6 @@ class hinted_config final std::chrono::milliseconds check_interval{ 1000 }; std::chrono::milliseconds block_cooldown{ 10000 }; unsigned hinting_threshold_percent{ 10 }; - unsigned vacancy_threshold_percent{ 20 }; }; /*