Skip to content

Commit

Permalink
Ignore AEC vacancy notification for hinted scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 7, 2023
1 parent 44eb324 commit 6ceacc1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
2 changes: 0 additions & 2 deletions nano/core_test/toml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 2 additions & 13 deletions nano/node/scheduler/hinted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ();
}
Expand All @@ -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 ();
}
1 change: 0 additions & 1 deletion nano/node/scheduler/hinted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

/*
Expand Down

0 comments on commit 6ceacc1

Please sign in to comment.