Add slow op in op tracker history.
Signed-off-by: Zhiqiang Wang <zhiqiang@xsky.com>
Mutex::Locker history_lock(ops_history_lock);
arrived.clear();
duration.clear();
+ slow_op.clear();
shutdown = true;
}
return;
duration.insert(make_pair(op->get_duration(), op));
arrived.insert(make_pair(op->get_initiated(), op));
+ if (op->get_duration() >= history_slow_op_threshold)
+ slow_op.insert(make_pair(op->get_initiated(), op));
cleanup(now);
}
duration.begin()->second));
duration.erase(duration.begin());
}
+
+ while (slow_op.size() > history_slow_op_size) {
+ slow_op.erase(make_pair(
+ slow_op.begin()->second->get_initiated(),
+ slow_op.begin()->second));
+ }
}
void OpHistory::dump_ops(utime_t now, Formatter *f)
class OpHistory {
set<pair<utime_t, TrackedOpRef> > arrived;
set<pair<double, TrackedOpRef> > duration;
+ set<pair<utime_t, TrackedOpRef> > slow_op;
Mutex ops_history_lock;
void cleanup(utime_t now);
bool shutdown;
uint32_t history_size;
uint32_t history_duration;
+ uint32_t history_slow_op_size;
+ uint32_t history_slow_op_threshold;
public:
OpHistory() : ops_history_lock("OpHistory::Lock"), shutdown(false),
- history_size(0), history_duration(0) {}
+ history_size(0), history_duration(0),
+ history_slow_op_size(0), history_slow_op_threshold(0) {}
~OpHistory() {
assert(arrived.empty());
assert(duration.empty());
+ assert(slow_op.empty());
}
void insert(utime_t now, TrackedOpRef op);
void dump_ops(utime_t now, Formatter *f);
history_size = new_size;
history_duration = new_duration;
}
+ void set_slow_op_size_and_threshold(uint32_t new_size, uint32_t new_threshold) {
+ history_slow_op_size = new_size;
+ history_slow_op_threshold = new_threshold;
+ }
};
struct ShardedTrackingData;
void set_history_size_and_duration(uint32_t new_size, uint32_t new_duration) {
history.set_size_and_duration(new_size, new_duration);
}
+ void set_history_slow_op_size_and_threshold(uint32_t new_size, uint32_t new_threshold) {
+ history.set_slow_op_size_and_threshold(new_size, new_threshold);
+ }
void set_tracking(bool enable) {
RWLock::WLocker l(lock);
tracking_enabled = enable;
OPTION(osd_num_op_tracker_shard, OPT_U32, 32) // The number of shards for holding the ops
OPTION(osd_op_history_size, OPT_U32, 20) // Max number of completed ops to track
OPTION(osd_op_history_duration, OPT_U32, 600) // Oldest completed op to track
+OPTION(osd_op_history_slow_op_size, OPT_U32, 20) // Max number of slow ops to track
+OPTION(osd_op_history_slow_op_threshold, OPT_DOUBLE, 10.0) // track the op if over this threshold
OPTION(osd_target_transaction_size, OPT_INT, 30) // to adjust various transactions that batch smaller items
OPTION(osd_failsafe_full_ratio, OPT_FLOAT, .97) // what % full makes an OSD "full" (failsafe)
OPTION(osd_fast_fail_on_connection_refused, OPT_BOOL, true) // immediately mark OSDs as down once they refuse to accept connections
cct->_conf->osd_op_log_threshold);
op_tracker.set_history_size_and_duration(cct->_conf->osd_op_history_size,
cct->_conf->osd_op_history_duration);
+ op_tracker.set_history_slow_op_size_and_threshold(cct->_conf->osd_op_history_slow_op_size,
+ cct->_conf->osd_op_history_slow_op_threshold);
}
OSD::~OSD()
op_tracker.set_history_size_and_duration(cct->_conf->osd_op_history_size,
cct->_conf->osd_op_history_duration);
}
+ if (changed.count("osd_op_history_slow_op_size") ||
+ changed.count("osd_op_history_slow_op_threshold")) {
+ op_tracker.set_history_slow_op_size_and_threshold(cct->_conf->osd_op_history_slow_op_size,
+ cct->_conf->osd_op_history_slow_op_threshold);
+ }
if (changed.count("osd_enable_op_tracker")) {
op_tracker.set_tracking(cct->_conf->osd_enable_op_tracker);
}