]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushTester: add new --show-mappings option
authorSage Weil <sage@redhat.com>
Tue, 2 Dec 2014 18:12:25 +0000 (10:12 -0800)
committerSage Weil <sage@redhat.com>
Sat, 7 Feb 2015 20:33:24 +0000 (12:33 -0800)
This makes --show-utilization and --show-statistics usable.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 3877f00877f53e9f86630c2d89e81ab9cff729ec)

15 files changed:
src/crush/CrushTester.cc
src/crush/CrushTester.h
src/test/cli/crushtool/help.t
src/test/cli/crushtool/set-choose.t
src/test/cli/crushtool/test-map-bobtail-tunables.t
src/test/cli/crushtool/test-map-firefly-tunables.t
src/test/cli/crushtool/test-map-indep.t
src/test/cli/crushtool/test-map-legacy-tunables.t
src/test/cli/crushtool/test-map-tries-vs-retries.t
src/test/cli/crushtool/test-map-vary-r-0.t
src/test/cli/crushtool/test-map-vary-r-1.t
src/test/cli/crushtool/test-map-vary-r-2.t
src/test/cli/crushtool/test-map-vary-r-3.t
src/test/cli/crushtool/test-map-vary-r-4.t
src/tools/crushtool.cc

index c86e0ef1b8f4f73a392c92868b3f37d8f9568629..3b45e53a6fe900754068136aaa8ff52ab1fc643e 100644 (file)
@@ -487,18 +487,18 @@ int CrushTester::test()
           vector<int> out;
 
           if (use_crush) {
-            if (output_statistics)
-              err << "CRUSH"; // prepend CRUSH to placement output
+            if (output_mappings)
+             err << "CRUSH"; // prepend CRUSH to placement output
             crush.do_rule(r, x, out, nr, weight);
           } else {
-            if (output_statistics)
-              err << "RNG"; // prepend RNG to placement output to denote simulation
+            if (output_mappings)
+             err << "RNG"; // prepend RNG to placement output to denote simulation
             // test our new monte carlo placement generator
             random_placement(r, out, nr, weight);
           }
 
-          if (output_statistics)
-            err << " rule " << r << " x " << x << " " << out << std::endl;
+         if (output_mappings)
+           err << " rule " << r << " x " << x << " " << out << std::endl;
 
           if (output_data_file)
             write_integer_indexed_vector_data_string(tester_data.placement_information, x, out);
index df5a157889890d016d8f5da3fb9eca7134b6b602..8de70f9d41d1cc2eec0bafb62b2c7176ce2eaa8d 100644 (file)
@@ -27,6 +27,7 @@ class CrushTester {
   bool output_utilization;
   bool output_utilization_all;
   bool output_statistics;
+  bool output_mappings;
   bool output_bad_mappings;
   bool output_choose_tries;
 
@@ -176,6 +177,7 @@ public:
       output_utilization(false),
       output_utilization_all(false),
       output_statistics(false),
+      output_mappings(false),
       output_bad_mappings(false),
       output_choose_tries(false),
       output_data_file(false),
@@ -226,6 +228,13 @@ public:
     return output_statistics;
   }
 
+  void set_output_mappings(bool b) {
+    output_mappings = b;
+  }
+  bool get_output_mappings() const {
+    return output_mappings;
+  }
+
   void set_output_bad_mappings(bool b) {
     output_bad_mappings = b;
   }
index 3b489301c48d6837c499be5a45c60f8abaf12dad..a9c6222fd71642dcdc15773c0ae964c375f2a3b0 100644 (file)
@@ -33,6 +33,7 @@
      --show utilization-all
                            include zero weight items
      --show-statistics     show chi squared statistics
+     --show-mappings       show mappings
      --show-bad-mappings   show bad mappings
      --show-choose-tries   show choose tries histogram
      --set-choose-local-tries N
index e160ad7814d5d63e3b369596a956e33a5f3fd8f8..b7ef59af2bdcf981716063ac9a10bba526bd4abd 100644 (file)
@@ -1,5 +1,5 @@
   $ crushtool -c "$TESTDIR/set-choose.crushmap.txt" -o set-choose.crushmap
-  $ crushtool -i set-choose.crushmap --test --show-statistics
+  $ crushtool -i set-choose.crushmap --test --show-mappings --show-statistics
   rule 0 (choose), x = 0..1023, numrep = 2..3
   CRUSH rule 0 x 0 [0,3]
   CRUSH rule 0 x 1 [0,8]
   CRUSH rule 5 x 1022 [1,6,4]
   CRUSH rule 5 x 1023 [3,2,8]
   rule 5 (chooseleaf-set) num_rep 3 result size == 3:\t1024/1024 (esc)
-  $ crushtool -i set-choose.crushmap --test --show-statistics --weight 0 0 --weight 1 0 --weight 3 0 --weight 4 0
+  $ crushtool -i set-choose.crushmap --test --show-mappings --show-statistics --weight 0 0 --weight 1 0 --weight 3 0 --weight 4 0
   rule 0 (choose), x = 0..1023, numrep = 2..3
   CRUSH rule 0 x 0 [2,5]
   CRUSH rule 0 x 1 [2,8]
   CRUSH rule 5 x 1022 [2,6,5]
   CRUSH rule 5 x 1023 [5,2,8]
   rule 5 (chooseleaf-set) num_rep 3 result size == 3:\t1024/1024 (esc)
-  $ crushtool -i set-choose.crushmap --test --show-statistics --weight 0 0 --weight 3 0 --weight 4 .5 --weight 5 0 --weight 6 .1 --weight 7 0
+  $ crushtool -i set-choose.crushmap --test --show-mappings --show-statistics --weight 0 0 --weight 3 0 --weight 4 .5 --weight 5 0 --weight 6 .1 --weight 7 0
   rule 0 (choose), x = 0..1023, numrep = 2..3
   CRUSH rule 0 x 0 [2,4]
   CRUSH rule 0 x 1 [2,8]
index 7c38260fec35f974be73dee78d6d8e31671b8d07..77f2ce86243ebba8655a2020315684c2700ea956 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-a.crushmap" --test --show-statistics --rule 0 --set-choose-local-tries 0 --set-choose-local-fallback-tries 0 --set-choose-total-tries 50 --set-chooseleaf-descend-once 1
+  $ crushtool -i "$TESTDIR/test-map-a.crushmap" --test --show-mappings --show-statistics --rule 0 --set-choose-local-tries 0 --set-choose-local-fallback-tries 0 --set-choose-total-tries 50 --set-chooseleaf-descend-once 1
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 0 (data), x = 0..1023, numrep = 1..10
   CRUSH rule 0 x 0 [36]
index 481b6fd5785c4a02aa541f7b62c57bfdd528cd30..a75e89fb1c59e3c0ef0c08c49c2fbc38361f131c 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-statistics --rule 0 --set-choose-local-tries 0 --set-choose-local-fallback-tries 0 --set-choose-total-tries 50 --set-chooseleaf-descend-once 1 --set-chooseleaf-vary-r 1 --weight 12 0 --weight 20 0 --weight 30 0
+  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-mappings --show-statistics --rule 0 --set-choose-local-tries 0 --set-choose-local-fallback-tries 0 --set-choose-total-tries 50 --set-chooseleaf-descend-once 1 --set-chooseleaf-vary-r 1 --weight 12 0 --weight 20 0 --weight 30 0
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 0 (data), x = 0..1023, numrep = 1..10
   CRUSH rule 0 x 0 [101]
index 5f6dbb348b791ef4c811da5c9480c38aa2a96192..f4ee371696a3b6c4716bc05b3312db057437b08e 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-indep.crushmap" --test --show-statistics --rule 1 --set-choose-local-tries 0 --set-choose-local-fallback-tries 0 --set-choose-total-tries 50 --set-chooseleaf-descend-once 2
+  $ crushtool -i "$TESTDIR/test-map-indep.crushmap" --test --show-mappings --show-statistics --rule 1 --set-choose-local-tries 0 --set-choose-local-fallback-tries 0 --set-choose-total-tries 50 --set-chooseleaf-descend-once 2
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 1 (metadata), x = 0..1023, numrep = 1..10
   CRUSH rule 1 x 0 [36]
index 12bf604aff3f007e7ffdcdb9b26ff5122575f6cb..fe28c70ea5ce36b228d2736665296cb085b3ffe9 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-a.crushmap" --test --show-statistics --rule 0
+  $ crushtool -i "$TESTDIR/test-map-a.crushmap" --test --show-mappings --show-statistics --rule 0
   rule 0 (data), x = 0..1023, numrep = 1..10
   CRUSH rule 0 x 0 [36]
   CRUSH rule 0 x 1 [876]
index 8eac25563a916c2843339fff162e36fa0f994656..2a49838d6f06a3c4e5f35d4744ef5c7d81887b3f 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-tries-vs-retries.crushmap" --test --show-statistics --weight 0 0 --weight 8 0
+  $ crushtool -i "$TESTDIR/test-map-tries-vs-retries.crushmap" --test --show-mappings --show-statistics --weight 0 0 --weight 8 0
   rule 0 (replicated_ruleset), x = 0..1023, numrep = 1..10
   CRUSH rule 0 x 0 [7]
   CRUSH rule 0 x 1 [10]
index 663ef650f839a4ec570f81b638b65220dbd6a592..eefd862ddb9102e646c5bd02040ff7f9c7690d4e 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-statistics --rule 3 --set-chooseleaf-vary-r 0 --weight 0 0 --weight 4 0 --weight 9 0
+  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-mappings --show-statistics --rule 3 --set-chooseleaf-vary-r 0 --weight 0 0 --weight 4 0 --weight 9 0
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 3 (delltestrule), x = 0..1023, numrep = 2..4
   CRUSH rule 3 x 0 [94,85]
index 4ac4c22292038f265b409856e698285d5200825b..a21b9d5f43d5821c5c69639b382afdfe3ff18ac9 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-statistics --rule 3 --set-chooseleaf-vary-r 1 --weight 0 0 --weight 4 0 --weight 9 0
+  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-mappings --show-statistics --rule 3 --set-chooseleaf-vary-r 1 --weight 0 0 --weight 4 0 --weight 9 0
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 3 (delltestrule), x = 0..1023, numrep = 2..4
   CRUSH rule 3 x 0 [94,6]
index c9e78c68908baf6f5b84ece9325609e6495245e0..eaf0542916ddc11aeefe75f45c8503fcaaf0af17 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-statistics --rule 3 --set-chooseleaf-vary-r 2 --weight 0 0 --weight 4 0 --weight 9 0
+  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-mappings --show-statistics --rule 3 --set-chooseleaf-vary-r 2 --weight 0 0 --weight 4 0 --weight 9 0
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 3 (delltestrule), x = 0..1023, numrep = 2..4
   CRUSH rule 3 x 0 [94,45]
index ad02e7373ffee78b7796c1382e9f4d5494b314c8..31943b2fff169948d20f0a32edfa4eae0cc97adf 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-statistics --rule 3 --set-chooseleaf-vary-r 3 --weight 0 0 --weight 4 0 --weight 9 0
+  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-mappings --show-statistics --rule 3 --set-chooseleaf-vary-r 3 --weight 0 0 --weight 4 0 --weight 9 0
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 3 (delltestrule), x = 0..1023, numrep = 2..4
   CRUSH rule 3 x 0 [94,85]
index 059da7712810e0d627933e6e8a29aa8c85543bbd..24cf0ba28921d6fe6db00a335102c2d462112e2b 100644 (file)
@@ -1,4 +1,4 @@
-  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-statistics --rule 3 --set-chooseleaf-vary-r 4 --weight 0 0 --weight 4 0 --weight 9 0
+  $ crushtool -i "$TESTDIR/test-map-vary-r.crushmap" --test --show-mappings --show-statistics --rule 3 --set-chooseleaf-vary-r 4 --weight 0 0 --weight 4 0 --weight 9 0
   crushtool successfully built or modified map.  Use '-o <file>' to write it out.
   rule 3 (delltestrule), x = 0..1023, numrep = 2..4
   CRUSH rule 3 x 0 [94,85]
index 8dcd79c387361e7c659510578347cb91b672573e..66ca6e3075dfb9d924340faf3c50ed8643c3038b 100644 (file)
@@ -118,6 +118,7 @@ void usage()
   cout << "   --show utilization-all\n";
   cout << "                         include zero weight items\n";
   cout << "   --show-statistics     show chi squared statistics\n";
+  cout << "   --show-mappings       show mappings\n";
   cout << "   --show-bad-mappings   show bad mappings\n";
   cout << "   --show-choose-tries   show choose tries histogram\n";
   cout << "   --set-choose-local-tries N\n";
@@ -233,6 +234,9 @@ int main(int argc, const char **argv)
     } else if (ceph_argparse_flag(args, i, "--show_statistics", (char*)NULL)) {
       display = true;
       tester.set_output_statistics(true);
+    } else if (ceph_argparse_flag(args, i, "--show_mappings", (char*)NULL)) {
+      display = true;
+      tester.set_output_mappings(true);
     } else if (ceph_argparse_flag(args, i, "--show_bad_mappings", (char*)NULL)) {
       display = true;
       tester.set_output_bad_mappings(true);