Skip to content

Commit

Permalink
MOVE SCHEDULERS TO NEW CONTAINER INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 3, 2023
1 parent 06d8af2 commit 546aae3
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (no
composite->add_component (collect_container_info (node.confirmation_height_processor, "confirmation_height_processor"));
composite->add_component (collect_container_info (node.distributed_work, "distributed_work"));
composite->add_component (collect_container_info (node.aggregator, "request_aggregator"));
composite->add_component (node.scheduler.collect_container_info ("election_scheduler"));
composite->add_component (node.scheduler.collect_container_info ().to_legacy_component ("election_scheduler"));
composite->add_component (node.vote_cache.collect_container_info ("vote_cache"));
composite->add_component (collect_container_info (node.generator, "vote_generator"));
composite->add_component (collect_container_info (node.final_generator, "vote_generator_final"));
Expand Down
8 changes: 4 additions & 4 deletions nano/node/scheduler/buckets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ void nano::scheduler::buckets::dump () const
std::cerr << "current: " << current - buckets_m.begin () << '\n';
}

std::unique_ptr<nano::container_info_component> nano::scheduler::buckets::collect_container_info (std::string const & name)
nano::experimental::container_info nano::scheduler::buckets::collect_container_info () const
{
auto composite = std::make_unique<container_info_composite> (name);
nano::experimental::container_info info;
for (auto i = 0; i < buckets_m.size (); ++i)
{
auto const & bucket = buckets_m[i];
composite->add_component (std::make_unique<container_info_leaf> (container_info{ std::to_string (i), bucket->size (), 0 }));
info.put (std::to_string (i), bucket->size ());
}
return composite;
return info;
}
2 changes: 1 addition & 1 deletion nano/node/scheduler/buckets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ class buckets final
void dump () const;
std::size_t index (nano::uint128_t const & balance) const;

std::unique_ptr<nano::container_info_component> collect_container_info (std::string const &);
nano::experimental::container_info collect_container_info () const;
};
} // namespace nano::scheduler
14 changes: 5 additions & 9 deletions nano/node/scheduler/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ void nano::scheduler::component::stop ()
priority.stop ();
}

std::unique_ptr<nano::container_info_component> nano::scheduler::component::collect_container_info (std::string const & name)
nano::experimental::container_info nano::scheduler::component::collect_container_info () const
{
nano::unique_lock<nano::mutex> lock{ mutex };

auto composite = std::make_unique<container_info_composite> (name);
//composite->add_component (hinted.collect_container_info ("hinted"));
composite->add_component (manual.collect_container_info ("manual"));
//composite->add_component (optimistic.collect_container_info ("optimistic"));
composite->add_component (priority.collect_container_info ("priority"));
return composite;
nano::experimental::container_info info;
info.add ("manual", manual.collect_container_info ());
info.add ("priority", priority.collect_container_info ());
return info;
}
6 changes: 3 additions & 3 deletions nano/node/scheduler/component.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include <nano/lib/container_info.hpp>
#include <nano/lib/locks.hpp>

#include <memory>
#include <string>

namespace nano
{
class container_info_component;
class node;
}
namespace nano::scheduler
Expand All @@ -23,7 +23,6 @@ class component final
std::unique_ptr<nano::scheduler::manual> manual_impl;
std::unique_ptr<nano::scheduler::optimistic> optimistic_impl;
std::unique_ptr<nano::scheduler::priority> priority_impl;
nano::mutex mutex;

public:
explicit component (nano::node & node);
Expand All @@ -34,8 +33,9 @@ class component final
// Stops all schedulers
void stop ();

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

public:
nano::scheduler::hinted & hinted;
nano::scheduler::manual & manual;
nano::scheduler::optimistic & optimistic;
Expand Down
10 changes: 5 additions & 5 deletions nano/node/scheduler/manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ void nano::scheduler::manual::run ()
}
}

std::unique_ptr<nano::container_info_component> nano::scheduler::manual::collect_container_info (std::string const & name)
nano::experimental::container_info nano::scheduler::manual::collect_container_info () const
{
nano::unique_lock<nano::mutex> lock{ mutex };

auto composite = std::make_unique<container_info_composite> (name);
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "queue", queue.size (), sizeof (decltype (queue)::value_type) }));
return composite;
}
nano::experimental::container_info info;
info.put ("queue", queue);
return info;
}
4 changes: 2 additions & 2 deletions nano/node/scheduler/manual.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class manual final
{
std::deque<std::tuple<std::shared_ptr<nano::block>, boost::optional<nano::uint128_t>, nano::election_behavior>> queue;
nano::node & node;
nano::mutex mutex;
mutable nano::mutex mutex;
nano::condition_variable condition;
bool stopped{ false };
std::thread thread;
Expand All @@ -41,6 +41,6 @@ class manual final
// Call action with confirmed block, may be different than what we started with
void push (std::shared_ptr<nano::block> const &, boost::optional<nano::uint128_t> const & = boost::none, nano::election_behavior = nano::election_behavior::normal);

std::unique_ptr<container_info_component> collect_container_info (std::string const & name);
nano::experimental::container_info collect_container_info () const;
}; // class manual
} // nano::scheduler
10 changes: 5 additions & 5 deletions nano/node/scheduler/priority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ void nano::scheduler::priority::run ()
}
}

std::unique_ptr<nano::container_info_component> nano::scheduler::priority::collect_container_info (std::string const & name)
nano::experimental::container_info nano::scheduler::priority::collect_container_info () const
{
nano::unique_lock<nano::mutex> lock{ mutex };

auto composite = std::make_unique<container_info_composite> (name);
composite->add_component (buckets->collect_container_info ("buckets"));
return composite;
}
nano::experimental::container_info info;
info.add ("buckets", buckets->collect_container_info ());
return info;
}
2 changes: 1 addition & 1 deletion nano/node/scheduler/priority.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class priority final
std::size_t size () const;
bool empty () const;

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

private: // Dependencies
nano::node & node;
Expand Down

0 comments on commit 546aae3

Please sign in to comment.