]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: more efficient PGMapTemp
authorSage Weil <sage@redhat.com>
Thu, 25 May 2017 16:13:58 +0000 (12:13 -0400)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:06:46 +0000 (13:06 -0400)
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 <sage@redhat.com>
src/test/osd/TestOSDMap.cc

index f937704fa77401d9279b4acf18e6036d35163588..b8258d4a1a4edb996226b5ed03595f1ee6b94602 100644 (file)
@@ -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());
+}