From c362dc1218de01fd3b1a69ff91c1f81f5e2651d6 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Mon, 3 Jun 2019 16:43:25 +0800 Subject: [PATCH] test: add parallel clean_pg_upmaps test 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 (cherry picked from commit a45112a9761d7b11f62cf4dac9f3a8e093cdd78f) --- src/test/osd/TestOSDMap.cc | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index dc85502d2c588..7da01f8b7e665 100644 --- a/src/test/osd/TestOSDMap.cc +++ b/src/test/osd/TestOSDMap.cc @@ -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 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; } -- 2.39.5