]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add parallel clean_pg_upmaps test 28619/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 3 Jun 2019 08:43:25 +0000 (16:43 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 18 Jun 2019 02:16:01 +0000 (10:16 +0800)
With parallel clean_pg_upmaps feature on, the total time cost
of the performance test which now can utilize up to 8 threads for
parallel upmap validating decreased from:

maybe_remove_pg_upmaps (~10000 pg_upmap_items) latency:104s

to:

clean_pg_upmaps (~10000 pg_upmap_items) latency:7s

Note that by default the mon uses only 4 worker threads for
CPU intensive background work, you could further increase
the "mon_cpu_threads" option value if you decided the
time-consuming of clean_pg_upmaps still matters.

Fixes: http://tracker.ceph.com/issues/40104
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit a45112a9761d7b11f62cf4dac9f3a8e093cdd78f)

src/test/osd/TestOSDMap.cc

index dc85502d2c58862f62322c42a040898d045dc4c8..7da01f8b7e6651f866e3d01a81ba935a0d0e3ef6 100644 (file)
@@ -2,6 +2,7 @@
 #include "gtest/gtest.h"
 #include "osd/OSDMap.h"
 #include "osd/OSDMapMapping.h"
+#include "mon/OSDMonitor.h"
 
 #include "global/global_context.h"
 #include "global/global_init.h"
@@ -183,6 +184,21 @@ public:
     cout << "first: " << *first << std::endl;;
     cout << "primary: " << *primary << std::endl;;
   }
+  void clean_pg_upmaps(CephContext *cct,
+                       const OSDMap& om,
+                       OSDMap::Incremental& pending_inc) {
+    int cpu_num = 8;
+    int pgs_per_chunk = 256;
+    ThreadPool tp(cct, "BUG_40104::clean_upmap_tp", "clean_upmap_tp", cpu_num);
+    tp.start();
+    ParallelPGMapper mapper(cct, &tp);
+    vector<pg_t> pgs_to_check;
+    om.get_upmap_pgs(&pgs_to_check);
+    OSDMonitor::CleanUpmapJob job(cct, om, pending_inc);
+    mapper.queue(&job, pgs_per_chunk, pgs_to_check);
+    job.wait();
+    tp.stop();
+  }
 };
 
 TEST_F(OSDMapTest, Create) {
@@ -627,7 +643,7 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
     nextmap.apply_incremental(pending_inc);
     ASSERT_TRUE(nextmap.have_pg_upmaps(pgid));
     OSDMap::Incremental new_pending_inc(nextmap.get_epoch() + 1);
-    nextmap.clean_pg_upmaps(g_ceph_context, &new_pending_inc);
+    clean_pg_upmaps(g_ceph_context, nextmap, new_pending_inc);
     nextmap.apply_incremental(new_pending_inc);
     ASSERT_TRUE(!nextmap.have_pg_upmaps(pgid));
   }
@@ -676,7 +692,7 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
     {
       // confirm *clean_pg_upmaps* won't do anything bad
       OSDMap::Incremental pending_inc(tmpmap.get_epoch() + 1);
-      tmpmap.clean_pg_upmaps(g_ceph_context, &pending_inc);
+      clean_pg_upmaps(g_ceph_context, tmpmap, pending_inc);
       tmpmap.apply_incremental(pending_inc);
       ASSERT_TRUE(tmpmap.have_pg_upmaps(ec_pgid));
     }
@@ -726,7 +742,7 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
     {
       // *clean_pg_upmaps* should be able to remove the above *bad* mapping
       OSDMap::Incremental pending_inc(tmpmap.get_epoch() + 1);
-      tmpmap.clean_pg_upmaps(g_ceph_context, &pending_inc);
+      clean_pg_upmaps(g_ceph_context, tmpmap, pending_inc);
       tmpmap.apply_incremental(pending_inc);
       ASSERT_TRUE(!tmpmap.have_pg_upmaps(ec_pgid));
     }
@@ -850,7 +866,7 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
     {
       // *clean_pg_upmaps* should not remove the above upmap_item
       OSDMap::Incremental pending_inc(tmp.get_epoch() + 1);
-      tmp.clean_pg_upmaps(g_ceph_context, &pending_inc);
+      clean_pg_upmaps(g_ceph_context, tmp, pending_inc);
       tmp.apply_incremental(pending_inc);
       ASSERT_TRUE(tmp.have_pg_upmaps(ec_pgid));
     }
@@ -915,7 +931,7 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
     {
       // STEP-2: apply cure
       OSDMap::Incremental pending_inc(osdmap.get_epoch() + 1);
-      osdmap.clean_pg_upmaps(g_ceph_context, &pending_inc);
+      clean_pg_upmaps(g_ceph_context, osdmap, pending_inc);
       osdmap.apply_incremental(pending_inc);
       {
         // validate pg_upmap is gone (reverted)
@@ -1049,7 +1065,7 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
     {
       // STEP-4: apply cure
       OSDMap::Incremental pending_inc(osdmap.get_epoch() + 1);
-      osdmap.clean_pg_upmaps(g_ceph_context, &pending_inc);
+      clean_pg_upmaps(g_ceph_context, osdmap, pending_inc);
       osdmap.apply_incremental(pending_inc);
       {
         // validate pg_upmap_items is gone (reverted)
@@ -1333,9 +1349,9 @@ TEST_F(OSDMapTest, BUG_40104) {
   {
     OSDMap::Incremental pending_inc(osdmap.get_epoch() + 1);
     auto start = ceph_clock_now();
-    osdmap.clean_pg_upmaps(g_ceph_context, &pending_inc);
+    clean_pg_upmaps(g_ceph_context, osdmap, pending_inc);
     auto latency = ceph_clock_now() - start;
-    std::cout << "maybe_remove_pg_upmaps (~" << big_pg_num
+    std::cout << "clean_pg_upmaps (~" << big_pg_num
               << " pg_upmap_items) latency:" << latency
               << std::endl;
   }