Skip to content

Commit

Permalink
Removing buckets::schedule as it's confusing and unnecessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Sep 8, 2023
1 parent 3480bfb commit f8695dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
28 changes: 9 additions & 19 deletions nano/node/scheduler/buckets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,22 @@
void nano::scheduler::buckets::next ()
{
++current;
if (current == schedule.end ())
if (current == buckets_m.end ())
{
current = schedule.begin ();
current = buckets_m.begin ();
}
}

/** Seek to the next non-empty bucket, if one exists */
void nano::scheduler::buckets::seek ()
{
next ();
for (std::size_t i = 0, n = schedule.size (); !buckets_m[*current]->available () && i < n; ++i)
for (std::size_t i = 0, n = buckets_m.size (); !(*current)->available () && i < n; ++i)
{
next ();
}
}

/** Initialise the schedule vector */
void nano::scheduler::buckets::populate_schedule ()
{
for (auto i = 0; i < buckets_m.size (); ++i)
{
schedule.push_back (i);
}
}

/**
* Prioritization constructor, construct a container containing approximately 'maximum' number of blocks.
* @param maximum number of blocks that this container can hold, this is a soft and approximate limit.
Expand Down Expand Up @@ -63,8 +54,7 @@ nano::scheduler::buckets::buckets (uint64_t maximum) :
{
buckets_m.push_back (std::make_unique<scheduler::bucket> (bucket_max));
}
populate_schedule ();
current = schedule.begin ();
current = buckets_m.begin ();
}

nano::scheduler::buckets::~buckets ()
Expand Down Expand Up @@ -96,17 +86,17 @@ void nano::scheduler::buckets::push (uint64_t time, std::shared_ptr<nano::block>
std::shared_ptr<nano::block> nano::scheduler::buckets::top () const
{
debug_assert (!empty ());
debug_assert (buckets_m[*current]->available ());
auto result = buckets_m[*current]->top ();
debug_assert ((*current)->available ());
auto result = (*current)->top ();
return result;
}

/** Pop the current block from the container and seek to the next block, if it exists */
void nano::scheduler::buckets::pop ()
{
debug_assert (!empty ());
debug_assert (buckets_m[*current]->available ());
auto & bucket = buckets_m[*current];
debug_assert ((*current)->available ());
auto & bucket = *current;
bucket->pop ();
seek ();
}
Expand Down Expand Up @@ -147,7 +137,7 @@ void nano::scheduler::buckets::dump () const
{
bucket->dump ();
}
std::cerr << "current: " << std::to_string (*current) << '\n';
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)
Expand Down
6 changes: 1 addition & 5 deletions nano/node/scheduler/buckets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ class buckets final
* the container writes a block to the lowest indexed bucket that has balance larger than the bucket's minimum value */
std::deque<nano::uint128_t> minimums;

/** Contains bucket indicies to iterate over when making the next scheduling decision */
std::deque<uint8_t> schedule;

/** index of bucket to read next */
decltype (schedule)::const_iterator current;
decltype (buckets_m)::const_iterator current;

/** maximum number of blocks in whole container, each bucket's maximum is maximum / bucket_number */
uint64_t const maximum;

void next ();
void seek ();
void populate_schedule ();

public:
buckets (uint64_t maximum = 250000u);
Expand Down

0 comments on commit f8695dc

Please sign in to comment.