Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: use 64 bit head+tail pointers in fair_queue #11

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions include/seastar/core/fair_queue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public:
};

class fair_group_rover {
uint32_t _weight = 0;
uint32_t _size = 0;
uint64_t _weight = 0;
uint64_t _size = 0;

public:
fair_group_rover(uint32_t weight, uint32_t size) noexcept;
fair_group_rover(uint64_t weight, uint64_t size) noexcept;

/*
* For both dimentions checks if the current rover is ahead of the
Expand Down Expand Up @@ -175,7 +175,6 @@ using priority_class_ptr = lw_shared_ptr<priority_class>;
/// the given time frame exceeds the disk throughput.
class fair_group {
using fair_group_atomic_rover = std::atomic<fair_group_rover>;
static_assert(fair_group_atomic_rover::is_always_lock_free);

fair_group_atomic_rover _capacity_tail;
fair_group_atomic_rover _capacity_head;
Expand Down
9 changes: 6 additions & 3 deletions src/core/fair_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ std::ostream& operator<<(std::ostream& os, fair_queue_ticket t) {
return os << t._weight << ":" << t._size;
}

fair_group_rover::fair_group_rover(uint32_t weight, uint32_t size) noexcept
fair_group_rover::fair_group_rover(uint64_t weight, uint64_t size) noexcept
: _weight(weight)
, _size(size)
{}

fair_queue_ticket fair_group_rover::maybe_ahead_of(const fair_group_rover& other) const noexcept {
return fair_queue_ticket(std::max<int32_t>(_weight - other._weight, 0),
std::max<int32_t>(_size - other._size, 0));

uint64_t weight_d = std::clamp<int64_t>(_weight - other._weight, 0, std::numeric_limits<int32_t>::max());
uint64_t size_d = std::clamp<int64_t>(_size - other._size, 0, std::numeric_limits<int32_t>::max());

return fair_queue_ticket(weight_d, size_d);
}

fair_group_rover fair_group_rover::operator+(fair_queue_ticket t) const noexcept {
Expand Down