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

osd/PG: Add two new mClock implementations of the PG sharded operator queue #14997

Merged
merged 1 commit into from Jun 26, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/common/OpQueue.h
Expand Up @@ -37,10 +37,11 @@ class OpQueue {
public:
// How many Ops are in the queue
virtual unsigned length() const = 0;
// Ops will be removed f evaluates to true, f may have sideeffects
virtual void remove_by_filter(
std::function<bool (T)> f) = 0;
// Ops of this priority should be deleted immediately
// Ops of this class should be deleted immediately. If out isn't
// nullptr then items should be added to the front in
// front-to-back order. The typical strategy is to visit items in
// the queue in *reverse* order and to use *push_front* to insert
// them into out.
virtual void remove_by_class(K k, std::list<T> *out) = 0;
// Enqueue op in the back of the strict queue
virtual void enqueue_strict(K cl, unsigned priority, T item) = 0;
Expand Down
63 changes: 0 additions & 63 deletions src/common/PrioritizedQueue.h
Expand Up @@ -45,24 +45,6 @@ class PrioritizedQueue : public OpQueue <T, K> {
int64_t min_cost;

typedef std::list<std::pair<unsigned, T> > ListPairs;
static unsigned filter_list_pairs(
ListPairs *l,
std::function<bool (T)> f) {
unsigned ret = 0;
for (typename ListPairs::iterator i = l->end();
i != l->begin();
) {
auto next = i;
--next;
if (f(next->second)) {
++ret;
l->erase(next);
} else {
i = next;
}
}
return ret;
}

struct SubQueue {
private:
Expand Down Expand Up @@ -142,24 +124,6 @@ class PrioritizedQueue : public OpQueue <T, K> {
bool empty() const {
return q.empty();
}
void remove_by_filter(
std::function<bool (T)> f) {
for (typename Classes::iterator i = q.begin();
i != q.end();
) {
size -= filter_list_pairs(&(i->second), f);
if (i->second.empty()) {
if (cur == i) {
++cur;
}
q.erase(i++);
} else {
++i;
}
}
if (cur == q.end())
cur = q.begin();
}
void remove_by_class(K k, std::list<T> *out) {
typename Classes::iterator i = q.find(k);
if (i == q.end()) {
Expand Down Expand Up @@ -251,33 +215,6 @@ class PrioritizedQueue : public OpQueue <T, K> {
return total;
}

void remove_by_filter(
std::function<bool (T)> f) final {
for (typename SubQueues::iterator i = queue.begin();
i != queue.end();
) {
unsigned priority = i->first;

i->second.remove_by_filter(f);
if (i->second.empty()) {
++i;
remove_queue(priority);
} else {
++i;
}
}
for (typename SubQueues::iterator i = high_queue.begin();
i != high_queue.end();
) {
i->second.remove_by_filter(f);
if (i->second.empty()) {
high_queue.erase(i++);
} else {
++i;
}
}
}

void remove_by_class(K k, std::list<T> *out = 0) final {
for (typename SubQueues::iterator i = queue.begin();
i != queue.end();
Expand Down
50 changes: 0 additions & 50 deletions src/common/WeightedPriorityQueue.h
Expand Up @@ -99,22 +99,6 @@ class WeightedPriorityQueue : public OpQueue <T, K>
unsigned get_size() const {
return lp.size();
}
unsigned filter_list_pairs(std::function<bool (T)>& f) {
unsigned count = 0;
// intrusive containers can't erase with a reverse_iterator
// so we have to walk backwards on our own. Since there is
// no iterator before begin, we have to test at the end.
for (Lit i = --lp.end();; --i) {
if (f(i->item)) {
i = lp.erase_and_dispose(i, DelItem<ListPair>());
++count;
}
if (i == lp.begin()) {
break;
}
}
return count;
}
unsigned filter_class(std::list<T>* out) {
unsigned count = 0;
for (Lit i = --lp.end();; --i) {
Expand Down Expand Up @@ -180,25 +164,6 @@ class WeightedPriorityQueue : public OpQueue <T, K>
check_end();
return ret;
}
unsigned filter_list_pairs(std::function<bool (T)>& f) {
unsigned count = 0;
// intrusive containers can't erase with a reverse_iterator
// so we have to walk backwards on our own. Since there is
// no iterator before begin, we have to test at the end.
for (Kit i = klasses.begin(); i != klasses.end();) {
count += i->filter_list_pairs(f);
if (i->empty()) {
if (next == i) {
++next;
}
i = klasses.erase_and_dispose(i, DelItem<Klass>());
} else {
++i;
}
}
check_end();
return count;
}
unsigned filter_class(K& cl, std::list<T>* out) {
unsigned count = 0;
Kit i = klasses.find(cl, MapKey<Klass, K>());
Expand Down Expand Up @@ -291,17 +256,6 @@ class WeightedPriorityQueue : public OpQueue <T, K>
}
return ret;
}
void filter_list_pairs(std::function<bool (T)>& f) {
for (Sit i = queues.begin(); i != queues.end();) {
size -= i->filter_list_pairs(f);
if (i->empty()) {
total_prio -= i->key;
i = queues.erase_and_dispose(i, DelItem<SubQueue>());
} else {
++i;
}
}
}
void filter_class(K& cl, std::list<T>* out) {
for (Sit i = queues.begin(); i != queues.end();) {
size -= i->filter_class(cl, out);
Expand Down Expand Up @@ -338,10 +292,6 @@ class WeightedPriorityQueue : public OpQueue <T, K>
unsigned length() const final {
return strict.size + normal.size;
}
void remove_by_filter(std::function<bool (T)> f) final {
strict.filter_list_pairs(f);
normal.filter_list_pairs(f);
}
void remove_by_class(K cl, std::list<T>* removed = 0) final {
strict.filter_class(cl, removed);
normal.filter_class(cl, removed);
Expand Down
28 changes: 27 additions & 1 deletion src/common/config_opts.h
Expand Up @@ -768,9 +768,35 @@ OPTION(osd_op_num_threads_per_shard_ssd, OPT_INT, 2)
OPTION(osd_op_num_shards, OPT_INT, 0)
OPTION(osd_op_num_shards_hdd, OPT_INT, 5)
OPTION(osd_op_num_shards_ssd, OPT_INT, 8)
OPTION(osd_op_queue, OPT_STR, "wpq") // PrioritzedQueue (prio), Weighted Priority Queue (wpq), or debug_random

// PrioritzedQueue (prio), Weighted Priority Queue (wpq ; default),
// mclock_opclass, mclock_client, or debug_random. "mclock_opclass"
// and "mclock_client" are based on the mClock/dmClock algorithm
// (Gulati, et al. 2010). "mclock_opclass" prioritizes based on the
// class the operation belongs to. "mclock_client" does the same but
// also works to ienforce fairness between clients. "debug_random"
// chooses among all four with equal probability.
OPTION(osd_op_queue, OPT_STR, "wpq")

OPTION(osd_op_queue_cut_off, OPT_STR, "low") // Min priority to go to strict queue. (low, high, debug_random)

// mClock priority queue parameters for five types of ops
OPTION(osd_op_queue_mclock_client_op_res, OPT_DOUBLE, 1000.0)
OPTION(osd_op_queue_mclock_client_op_wgt, OPT_DOUBLE, 500.0)
OPTION(osd_op_queue_mclock_client_op_lim, OPT_DOUBLE, 0.0)
OPTION(osd_op_queue_mclock_osd_subop_res, OPT_DOUBLE, 1000.0)
OPTION(osd_op_queue_mclock_osd_subop_wgt, OPT_DOUBLE, 500.0)
OPTION(osd_op_queue_mclock_osd_subop_lim, OPT_DOUBLE, 0.0)
OPTION(osd_op_queue_mclock_snap_res, OPT_DOUBLE, 0.0)
OPTION(osd_op_queue_mclock_snap_wgt, OPT_DOUBLE, 1.0)
OPTION(osd_op_queue_mclock_snap_lim, OPT_DOUBLE, 0.001)
OPTION(osd_op_queue_mclock_recov_res, OPT_DOUBLE, 0.0)
OPTION(osd_op_queue_mclock_recov_wgt, OPT_DOUBLE, 1.0)
OPTION(osd_op_queue_mclock_recov_lim, OPT_DOUBLE, 0.001)
OPTION(osd_op_queue_mclock_scrub_res, OPT_DOUBLE, 0.0)
OPTION(osd_op_queue_mclock_scrub_wgt, OPT_DOUBLE, 1.0)
OPTION(osd_op_queue_mclock_scrub_lim, OPT_DOUBLE, 0.001)

OPTION(osd_ignore_stale_divergent_priors, OPT_BOOL, false) // do not assert on divergent_prior entries which aren't in the log and whose on-disk objects are newer

// Set to true for testing. Users should NOT set this.
Expand Down