Add election_scheduler stats (#4151)
This commit is contained in:
parent
11b1d4ca62
commit
b0d9ca8a46
4 changed files with 26 additions and 7 deletions
|
|
@ -41,6 +41,7 @@ enum class type : uint8_t
|
||||||
active_timeout,
|
active_timeout,
|
||||||
backlog,
|
backlog,
|
||||||
unchecked,
|
unchecked,
|
||||||
|
election_scheduler,
|
||||||
|
|
||||||
_last // Must be the last enum
|
_last // Must be the last enum
|
||||||
};
|
};
|
||||||
|
|
@ -264,6 +265,12 @@ enum class detail : uint8_t
|
||||||
satisfied,
|
satisfied,
|
||||||
trigger,
|
trigger,
|
||||||
|
|
||||||
|
// election scheduler
|
||||||
|
insert_manual,
|
||||||
|
insert_priority,
|
||||||
|
insert_priority_success,
|
||||||
|
erase_oldest,
|
||||||
|
|
||||||
_last // Must be the last enum
|
_last // Must be the last enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#include <nano/node/election_scheduler.hpp>
|
#include <nano/node/election_scheduler.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
|
||||||
nano::election_scheduler::election_scheduler (nano::node & node) :
|
nano::election_scheduler::election_scheduler (nano::node & node_a, nano::stats & stats_a) :
|
||||||
node{ node }
|
node{ node_a },
|
||||||
|
stats{ stats_a }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,6 +56,7 @@ bool nano::election_scheduler::activate (nano::account const & account_a, nano::
|
||||||
debug_assert (block != nullptr);
|
debug_assert (block != nullptr);
|
||||||
if (node.ledger.dependents_confirmed (transaction, *block))
|
if (node.ledger.dependents_confirmed (transaction, *block))
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::activated);
|
||||||
auto balance = node.ledger.balance (transaction, hash);
|
auto balance = node.ledger.balance (transaction, hash);
|
||||||
auto previous_balance = node.ledger.balance (transaction, conf_info.frontier);
|
auto previous_balance = node.ledger.balance (transaction, conf_info.frontier);
|
||||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||||
|
|
@ -133,9 +135,12 @@ void nano::election_scheduler::run ()
|
||||||
debug_assert ((std::this_thread::yield (), true)); // Introduce some random delay in debug builds
|
debug_assert ((std::this_thread::yield (), true)); // Introduce some random delay in debug builds
|
||||||
if (!stopped)
|
if (!stopped)
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::loop);
|
||||||
|
|
||||||
if (overfill_predicate ())
|
if (overfill_predicate ())
|
||||||
{
|
{
|
||||||
lock.unlock ();
|
lock.unlock ();
|
||||||
|
stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::erase_oldest);
|
||||||
node.active.erase_oldest ();
|
node.active.erase_oldest ();
|
||||||
}
|
}
|
||||||
else if (manual_queue_predicate ())
|
else if (manual_queue_predicate ())
|
||||||
|
|
@ -143,6 +148,7 @@ void nano::election_scheduler::run ()
|
||||||
auto const [block, previous_balance, election_behavior] = manual_queue.front ();
|
auto const [block, previous_balance, election_behavior] = manual_queue.front ();
|
||||||
manual_queue.pop_front ();
|
manual_queue.pop_front ();
|
||||||
lock.unlock ();
|
lock.unlock ();
|
||||||
|
stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::insert_manual);
|
||||||
node.active.insert (block, election_behavior);
|
node.active.insert (block, election_behavior);
|
||||||
}
|
}
|
||||||
else if (priority_queue_predicate ())
|
else if (priority_queue_predicate ())
|
||||||
|
|
@ -151,10 +157,15 @@ void nano::election_scheduler::run ()
|
||||||
priority.pop ();
|
priority.pop ();
|
||||||
lock.unlock ();
|
lock.unlock ();
|
||||||
std::shared_ptr<nano::election> election;
|
std::shared_ptr<nano::election> election;
|
||||||
election = node.active.insert (block).election;
|
stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::insert_priority);
|
||||||
if (election != nullptr)
|
auto result = node.active.insert (block);
|
||||||
|
if (result.inserted)
|
||||||
{
|
{
|
||||||
election->transition_active ();
|
stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::insert_priority_success);
|
||||||
|
}
|
||||||
|
if (result.election != nullptr)
|
||||||
|
{
|
||||||
|
result.election->transition_active ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class node;
|
||||||
class election_scheduler final
|
class election_scheduler final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
election_scheduler (nano::node &);
|
election_scheduler (nano::node &, nano::stats &);
|
||||||
~election_scheduler ();
|
~election_scheduler ();
|
||||||
|
|
||||||
void start ();
|
void start ();
|
||||||
|
|
@ -43,6 +43,7 @@ public:
|
||||||
|
|
||||||
private: // Dependencies
|
private: // Dependencies
|
||||||
nano::node & node;
|
nano::node & node;
|
||||||
|
nano::stats & stats;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run ();
|
void run ();
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co
|
||||||
generator{ config, ledger, wallets, vote_processor, history, network, stats, /* non-final */ false },
|
generator{ config, ledger, wallets, vote_processor, history, network, stats, /* non-final */ false },
|
||||||
final_generator{ config, ledger, wallets, vote_processor, history, network, stats, /* final */ true },
|
final_generator{ config, ledger, wallets, vote_processor, history, network, stats, /* final */ true },
|
||||||
active (*this, confirmation_height_processor),
|
active (*this, confirmation_height_processor),
|
||||||
scheduler{ *this },
|
scheduler{ *this, stats },
|
||||||
hinting{ nano::nodeconfig_to_hinted_scheduler_config (config), *this, inactive_vote_cache, active, online_reps, stats },
|
hinting{ nano::nodeconfig_to_hinted_scheduler_config (config), *this, inactive_vote_cache, active, online_reps, stats },
|
||||||
aggregator (config, stats, generator, final_generator, history, ledger, wallets, active),
|
aggregator (config, stats, generator, final_generator, history, ledger, wallets, active),
|
||||||
wallets (wallets_store.init_error (), *this),
|
wallets (wallets_store.init_error (), *this),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue