From: Sage Weil Date: Thu, 25 May 2017 16:13:58 +0000 (-0400) Subject: osd/OSDMap: more efficient PGMapTemp X-Git-Tag: ses5-milestone6~8^2~19^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebc496d7f4b95556f08758d4ec20c3b0efdcaf1c;p=ceph.git osd/OSDMap: more efficient PGMapTemp Use a flat_map with pointers into a buffer with the actual data. For a decoded mapping, we have just two allocations (one for flat_map and one for the encoded buffer). This can get slow if you make lots of incremental changes after the fact since flat_map is not efficient for modifications at large sizes. :/ Signed-off-by: Sage Weil --- diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index f937704fa77..b8258d4a1a4 100644 --- a/src/test/osd/TestOSDMap.cc +++ b/src/test/osd/TestOSDMap.cc @@ -434,3 +434,19 @@ TEST_F(OSDMapTest, PrimaryAffinity) { osdmap.set_primary_affinity(1, 0x10000); } } + +TEST(PGTempMap, basic) +{ + PGTempMap m; + pg_t a(1,1); + for (unsigned i=3; i<1000; ++i) { + pg_t x(i, 1); + m.set(x, {i}); + } + pg_t b(2,1); + m.set(a, {1, 2}); + ASSERT_NE(m.find(a), m.end()); + ASSERT_EQ(m.find(a), m.begin()); + ASSERT_EQ(m.find(b), m.end()); + ASSERT_EQ(998u, m.size()); +}