From ebc496d7f4b95556f08758d4ec20c3b0efdcaf1c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 25 May 2017 12:13:58 -0400 Subject: [PATCH] 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 --- src/test/osd/TestOSDMap.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index f937704fa7740..b8258d4a1a4ed 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()); +} -- 2.39.5