Skip to content

Commit

Permalink
Collect container info
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed May 24, 2024
1 parent 5a490b7 commit 1e1547e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions nano/lib/thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void nano::thread_pool::set_thread_names (nano::thread_role::name thread_name)
thread_names_latch.wait ();
}

std::unique_ptr<nano::container_info_component> nano::collect_container_info (thread_pool & thread_pool, std::string const & name)
std::unique_ptr<nano::container_info_component> nano::thread_pool::collect_container_info (std::string const & name) const
{
auto composite = std::make_unique<container_info_composite> (name);
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "count", thread_pool.num_queued_tasks (), sizeof (std::function<void ()>) }));
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "count", num_queued_tasks (), sizeof (std::function<void ()>) }));
return composite;
}
4 changes: 2 additions & 2 deletions nano/lib/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class thread_pool final
/** Returns the number of tasks which are awaiting execution by the thread pool **/
uint64_t num_queued_tasks () const;

std::unique_ptr<nano::container_info_component> collect_container_info (std::string const & name) const;

private:
nano::mutex mutex;
std::atomic<bool> stopped{ false };
Expand All @@ -48,6 +50,4 @@ class thread_pool final
std::latch thread_names_latch;
void set_thread_names (nano::thread_role::name thread_name);
};

std::unique_ptr<nano::container_info_component> collect_container_info (thread_pool & thread_pool, std::string const & name);
} // namespace nano
8 changes: 4 additions & 4 deletions nano/node/confirming_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nano::confirming_set::confirming_set (nano::ledger & ledger_a, nano::stats & sta
ledger{ ledger_a },
stats{ stats_a },
batch_time{ batch_time_a },
workers{ 1, nano::thread_role::name::confirmation_height_notifications }
notification_workers{ 1, nano::thread_role::name::confirmation_height_notifications }
{
batch_cemented.add ([this] (auto const & notification) {
for (auto const & [block, confirmation_root] : notification.cemented)
Expand Down Expand Up @@ -70,7 +70,7 @@ void nano::confirming_set::stop ()
{
thread.join ();
}
workers.stop ();
notification_workers.stop ();
}

bool nano::confirming_set::exists (nano::block_hash const & hash) const
Expand Down Expand Up @@ -160,7 +160,7 @@ void nano::confirming_set::run_batch (std::unique_lock<std::mutex> & lock)
.already_cemented = std::move (already)
};

workers.push_task ([this, notification = std::move (notification)] () {
notification_workers.push_task ([this, notification = std::move (notification)] () {
stats.inc (nano::stat::type::confirming_set, nano::stat::detail::notify);
batch_cemented.notify (notification);
});
Expand All @@ -177,6 +177,6 @@ std::unique_ptr<nano::container_info_component> nano::confirming_set::collect_co
auto composite = std::make_unique<container_info_composite> (name);
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "set", set.size (), sizeof (typename decltype (set)::value_type) }));
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "processing", processing.size (), sizeof (typename decltype (processing)::value_type) }));
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "notifications", workers.num_queued_tasks (), sizeof (std::function<void ()>) }));
composite->add_component (notification_workers.collect_container_info ("notification_workers"));
return composite;
}
3 changes: 2 additions & 1 deletion nano/node/confirming_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class confirming_set final
// Added blocks will remain in this set until after ledger has them marked as confirmed.
bool exists (nano::block_hash const & hash) const;
std::size_t size () const;

std::unique_ptr<container_info_component> collect_container_info (std::string const & name) const;

public: // Events
Expand Down Expand Up @@ -66,7 +67,7 @@ class confirming_set final
std::unordered_set<nano::block_hash> set;
std::unordered_set<nano::block_hash> processing;

nano::thread_pool workers;
nano::thread_pool notification_workers;

bool stopped{ false };
mutable std::mutex mutex;
Expand Down
8 changes: 4 additions & 4 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (no
composite->add_component (node.tcp_listener.collect_container_info ("tcp_listener"));
composite->add_component (collect_container_info (node.network, "network"));
composite->add_component (node.telemetry.collect_container_info ("telemetry"));
composite->add_component (collect_container_info (node.workers, "workers"));
composite->add_component (collect_container_info (node.bootstrap_workers, "bootstrap_workers"));
composite->add_component (collect_container_info (node.wallet_workers, "wallet_workers"));
composite->add_component (collect_container_info (node.election_workers, "election_workers"));
composite->add_component (node.workers.collect_container_info ("workers"));
composite->add_component (node.bootstrap_workers.collect_container_info ("bootstrap_workers"));
composite->add_component (node.wallet_workers.collect_container_info ("wallet_workers"));
composite->add_component (node.election_workers.collect_container_info ("election_workers"));
composite->add_component (collect_container_info (node.observers, "observers"));
composite->add_component (collect_container_info (node.wallets, "wallets"));
composite->add_component (node.vote_processor.collect_container_info ("vote_processor"));
Expand Down

0 comments on commit 1e1547e

Please sign in to comment.