Skip to content

Commit

Permalink
crushtool: allow user to select output reporting in blocks
Browse files Browse the repository at this point in the history
Signed-off-by: caleb miles <[email protected]>
  • Loading branch information
caleb miles authored and Sage Weil committed Jun 6, 2012
1 parent dde85a2 commit af4d8db
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ src/omapbench

# temporary directory used by e.g. "make distcheck", e.g. ceph-0.42
/ceph-[0-9]*/
/nbproject/private/
20 changes: 10 additions & 10 deletions src/crush/CrushTester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ int CrushTester::test()
vector<int> out;

if (use_crush) {
if (verbose > 2)
if (output_statistics)
err << "CRUSH"; // prepend CRUSH to placement output
crush.do_rule(r, x, out, nr, weight);
} else {
if (verbose > 2)
if (output_statistics)
err << "RNG"; // prepend RNG to placement output to denote simulation

#ifdef HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION
Expand All @@ -213,9 +213,9 @@ int CrushTester::test()
#endif
}

if (verbose)
if (verbose>1 )
err << " rule " << r << " x " << x << " " << out << std::endl;

if (output_statistics)
err << " rule " << r << " x " << x << " " << out << std::endl;
for (unsigned i = 0; i < out.size(); i++) {
per[out[i]]++;
temporary_per[out[i]]++;
Expand All @@ -234,7 +234,7 @@ int CrushTester::test()
}

for (unsigned i = 0; i < per.size(); i++)
if (verbose>1 )
if (output_utilization && !output_statistics)
err << " device " << i
<< ":\t" << per[i]
<< std::endl;
Expand Down Expand Up @@ -262,9 +262,9 @@ int CrushTester::test()
}
#endif

if (verbose > 1)
if (output_statistics)
for (unsigned i = 0; i < per.size(); i++) {
if (verbose < 5 ){
if (output_utilization && num_batches > 1){
if (num_objects_expected[i] > 0 && per[i] > 0) {
err << " device " << i << ":\t"
<< "\t" << " stored " << ": " << per[i]
Expand All @@ -276,7 +276,7 @@ int CrushTester::test()
#endif
<< std::endl;
}
} else {
} else if (output_utilization_all && num_batches > 1) {
err << " device " << i << ":\t"
<< "\t" << " stored " << ": " << per[i]
<< "\t" << " expected " << ": " << num_objects_expected[i]
Expand All @@ -297,7 +297,7 @@ int CrushTester::test()
//err << " total system weight (dec) = " << (total_weight / (float) 0x10000) << std::endl;
//err << " number of buckets = " << num_buckets << std::endl;

if (num_batches > 1) {
if (num_batches > 1 && output_statistics) {
err << " " << num_devices_failing_at_five_percent << "/" << num_devices_active << " ("
<< (100.0*((float) num_devices_failing_at_five_percent / (float) num_devices_active))
<< "%) devices failed testing at 5% confidence level" << std::endl;
Expand Down
9 changes: 7 additions & 2 deletions src/crush/CrushTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class CrushTester {
float mark_down_percentage;
int mark_down_start;
int down_range;
bool output_utilization;
bool output_utilization_all;
bool output_statistics;

public:
CrushTester(CrushWrapper& c, ostream& eo, int verbosity=0)
Expand All @@ -42,8 +45,10 @@ class CrushTester {
down_range(1)
{ }

void set_verbosity(int v) {
verbose = v;
void set_output(bool set_output_utilization, bool set_output_utilization_all, bool set_output_statistics) {
output_utilization = set_output_utilization;
output_utilization_all = set_output_utilization_all;
output_statistics = set_output_statistics;
}
void set_batches(int b) {
num_batches = b;
Expand Down
21 changes: 14 additions & 7 deletions src/crushtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void usage()
cout << " [--min-rule r] [--max-rule r] [--rule r]\n";
cout << " [--num-rep n]\n";
cout << " [--batches b]\n";
cout << " [--simulate]\n";
cout << " --simulate simulate placements using a RNG\n";
cout << " [--weight|-w devno weight]\n";
cout << " where weight is 0 to 1.0\n";
cout << " -i mapfn --add-item id weight name [--loc type name ...]\n";
Expand All @@ -74,6 +74,9 @@ void usage()
cout << " reweight a given item (and adjust ancestor\n"
<< " weights as needed)\n";
cout << " -i mapfn --reweight recalculate all bucket weights\n";
cout << " --output-utilization output OSD usage\n";
cout << " --output utilization-all include zero weight items\n";
cout << " --output-statistics output chi squared statistics\n";
exit(1);
}

Expand Down Expand Up @@ -105,6 +108,9 @@ int main(int argc, const char **argv)
bool decompile = false;
bool test = false;
bool verbose = false;
bool output_utilization = false;
bool output_utilization_all = false;
bool output_statistics = false;

bool reweight = false;
int add_item = -1;
Expand Down Expand Up @@ -144,12 +150,12 @@ int main(int argc, const char **argv)
outfn = val;
} else if (ceph_argparse_flag(args, i, "-v", "--verbose", (char*)NULL)) {
verbose = true;
} else if (ceph_argparse_withint(args, i, &x, &err, "-vl", "--verbose-level", (char*)NULL)) {
if (!err.str().empty()) {
cerr << err.str() << std::endl;
exit(EXIT_FAILURE);
}
tester.set_verbosity(x);
} else if (ceph_argparse_flag(args, i, "--output_utilization", (char*)NULL)) {
output_utilization = true;
} else if (ceph_argparse_flag(args, i, "--output_utilization_all", (char*)NULL)) {
output_utilization_all = true;
} else if (ceph_argparse_flag(args, i, "--output_statistics", (char*)NULL)) {
output_statistics = true;
} else if (ceph_argparse_witharg(args, i, &val, "-c", "--compile", (char*)NULL)) {
srcfn = val;
compile = true;
Expand Down Expand Up @@ -552,6 +558,7 @@ int main(int argc, const char **argv)
}

if (test) {
tester.set_output(output_utilization, output_utilization_all, output_statistics);
int r = tester.test();
if (r < 0)
exit(1);
Expand Down

0 comments on commit af4d8db

Please sign in to comment.