crush: add infrastructure around new chooseleaf_vary_r tunable

- encoding
- feature bit
- decompile/compile

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2014-02-04 15:31:40 -08:00
parent a8e6c9fbf8
commit e20a55d906
7 changed files with 62 additions and 5 deletions

View File

@ -188,6 +188,8 @@ int CrushCompiler::decompile(ostream &out)
out << "tunable choose_total_tries " << crush.get_choose_total_tries() << "\n";
if (crush.get_chooseleaf_descend_once() != 0)
out << "tunable chooseleaf_descend_once " << crush.get_chooseleaf_descend_once() << "\n";
if (crush.get_chooseleaf_vary_r() != 0)
out << "tunable chooseleaf_vary_r " << crush.get_chooseleaf_vary_r() << "\n";
out << "\n# devices\n";
for (int i=0; i<crush.get_max_devices(); i++) {
@ -359,6 +361,8 @@ int CrushCompiler::parse_tunable(iter_t const& i)
crush.set_choose_total_tries(val);
else if (name == "chooseleaf_descend_once")
crush.set_chooseleaf_descend_once(val);
else if (name == "chooseleaf_vary_r")
crush.set_chooseleaf_vary_r(val);
else {
err << "tunable " << name << " not recognized" << std::endl;
return -1;

View File

@ -872,6 +872,7 @@ void CrushWrapper::encode(bufferlist& bl, bool lean) const
::encode(crush->choose_local_fallback_tries, bl);
::encode(crush->choose_total_tries, bl);
::encode(crush->chooseleaf_descend_once, bl);
::encode(crush->chooseleaf_vary_r, bl);
}
static void decode_32_or_64_string_map(map<int32_t,string>& m, bufferlist::iterator& blp)
@ -952,6 +953,9 @@ void CrushWrapper::decode(bufferlist::iterator& blp)
if (!blp.end()) {
::decode(crush->chooseleaf_descend_once, blp);
}
if (!blp.end()) {
::decode(crush->chooseleaf_vary_r, blp);
}
finalize();
}
catch (...) {
@ -1137,7 +1141,9 @@ void CrushWrapper::dump_tunables(Formatter *f) const
f->dump_int("chooseleaf_descend_once", get_chooseleaf_descend_once());
// be helpful about it
if (has_bobtail_tunables())
if (has_firefly_tunables())
f->dump_string("profile", "firefly");
else if (has_bobtail_tunables())
f->dump_string("profile", "bobtail");
else if (has_argonaut_tunables())
f->dump_string("profile", "argonaut");

View File

@ -105,19 +105,28 @@ public:
crush->choose_local_fallback_tries = 5;
crush->choose_total_tries = 19;
crush->chooseleaf_descend_once = 0;
crush->chooseleaf_vary_r = 0;
}
void set_tunables_bobtail() {
crush->choose_local_tries = 0;
crush->choose_local_fallback_tries = 0;
crush->choose_total_tries = 50;
crush->chooseleaf_descend_once = 1;
crush->chooseleaf_vary_r = 0;
}
void set_tunables_firefly() {
crush->choose_local_tries = 0;
crush->choose_local_fallback_tries = 0;
crush->choose_total_tries = 50;
crush->chooseleaf_descend_once = 1;
crush->chooseleaf_vary_r = 1;
}
void set_tunables_legacy() {
set_tunables_argonaut();
}
void set_tunables_optimal() {
set_tunables_bobtail();
set_tunables_firefly();
}
void set_tunables_default() {
set_tunables_bobtail();
@ -151,23 +160,40 @@ public:
crush->chooseleaf_descend_once = !!n;
}
int get_chooseleaf_vary_r() const {
return crush->chooseleaf_vary_r;
}
void set_chooseleaf_vary_r(int n) {
crush->chooseleaf_vary_r = n;
}
bool has_argonaut_tunables() const {
return
crush->choose_local_tries == 2 &&
crush->choose_local_fallback_tries == 5 &&
crush->choose_total_tries == 19 &&
crush->chooseleaf_descend_once == 0;
crush->chooseleaf_descend_once == 0 &&
crush->chooseleaf_vary_r == 0;
}
bool has_bobtail_tunables() const {
return
crush->choose_local_tries == 0 &&
crush->choose_local_fallback_tries == 0 &&
crush->choose_total_tries == 50 &&
crush->chooseleaf_descend_once == 1;
crush->chooseleaf_descend_once == 1 &&
crush->chooseleaf_vary_r == 0;
}
bool has_firefly_tunables() const {
return
crush->choose_local_tries == 0 &&
crush->choose_local_fallback_tries == 0 &&
crush->choose_total_tries == 50 &&
crush->chooseleaf_descend_once == 1 &&
crush->chooseleaf_vary_r == 1;
}
bool has_optimal_tunables() const {
return has_bobtail_tunables();
return has_firefly_tunables();
}
bool has_legacy_tunables() const {
return has_argonaut_tunables();
@ -183,6 +209,10 @@ public:
return
crush->chooseleaf_descend_once != 0;
}
bool has_nondefault_tunables3() const {
return
crush->chooseleaf_vary_r != 0;
}
bool has_v2_rules() const;

View File

@ -48,6 +48,7 @@
this bit to determine if peers support NAK messages. */
#define CEPH_FEATURE_OSDMAP_ENC (1ULL<<39)
#define CEPH_FEATURE_MDS_INLINE_DATA (1ULL<<40)
#define CEPH_FEATURE_CRUSH_TUNABLES3 (1ULL<<41)
/*
* The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature
@ -116,6 +117,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
CEPH_FEATURE_OSD_ERASURE_CODES | \
CEPH_FEATURE_OSDMAP_ENC | \
CEPH_FEATURE_MDS_INLINE_DATA | \
CEPH_FEATURE_CRUSH_TUNABLES3 | \
0ULL)
#define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL
@ -126,6 +128,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
#define CEPH_FEATURES_CRUSH \
(CEPH_FEATURE_CRUSH_TUNABLES | \
CEPH_FEATURE_CRUSH_TUNABLES2 | \
CEPH_FEATURE_CRUSH_TUNABLES3 | \
CEPH_FEATURE_CRUSH_V2)
#endif

View File

@ -932,6 +932,8 @@ uint64_t OSDMap::get_features(uint64_t *pmask) const
features |= CEPH_FEATURE_CRUSH_TUNABLES2;
if (crush->has_v2_rules())
features |= CEPH_FEATURE_CRUSH_V2;
if (crush->has_nondefault_tunables3())
features |= CEPH_FEATURE_CRUSH_TUNABLES3;
mask |= CEPH_FEATURES_CRUSH;
for (map<int64_t,pg_pool_t>::const_iterator p = pools.begin(); p != pools.end(); ++p) {

View File

@ -44,6 +44,8 @@
set choose total descent attempts
--set-chooseleaf-descend-once <0|1>
set chooseleaf to (not) retry the recursive descent
--set-chooseleaf-vary-r <0|1>
set chooseleaf to (not) vary r based on parent
--output-name name
prepend the data file(s) generated during the
testing routine with name

View File

@ -129,6 +129,8 @@ void usage()
cout << " set choose total descent attempts\n";
cout << " --set-chooseleaf-descend-once <0|1>\n";
cout << " set chooseleaf to (not) retry the recursive descent\n";
cout << " --set-chooseleaf-vary-r <0|1>\n";
cout << " set chooseleaf to (not) vary r based on parent\n";
cout << " --output-name name\n";
cout << " prepend the data file(s) generated during the\n";
cout << " testing routine with name\n";
@ -187,6 +189,7 @@ int main(int argc, const char **argv)
int choose_local_fallback_tries = -1;
int choose_total_tries = -1;
int chooseleaf_descend_once = -1;
int chooseleaf_vary_r = -1;
CrushWrapper crush;
@ -257,6 +260,9 @@ int main(int argc, const char **argv)
} else if (ceph_argparse_withint(args, i, &chooseleaf_descend_once, &err,
"--set_chooseleaf_descend_once", (char*)NULL)) {
adjust = true;
} else if (ceph_argparse_withint(args, i, &chooseleaf_vary_r, &err,
"--set_chooseleaf_vary_r", (char*)NULL)) {
adjust = true;
} else if (ceph_argparse_flag(args, i, "--reweight", (char*)NULL)) {
reweight = true;
} else if (ceph_argparse_withint(args, i, &add_item, &err, "--add_item", (char*)NULL)) {
@ -702,6 +708,10 @@ int main(int argc, const char **argv)
crush.set_chooseleaf_descend_once(chooseleaf_descend_once);
modified = true;
}
if (chooseleaf_vary_r >= 0) {
crush.set_chooseleaf_vary_r(chooseleaf_vary_r);
modified = true;
}
if (modified) {
crush.finalize();