From: Sage Weil Date: Wed, 4 Apr 2018 02:07:23 +0000 (-0500) Subject: osd: avoid OSDShardPGSlot allocation in fast path X-Git-Tag: v13.1.0~390^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d14221d5d6a44ea61cf7b70b232e88b058608fc6;p=ceph.git osd: avoid OSDShardPGSlot allocation in fast path If the entry already exists, we don't want to construct the PGSlot and then throw it out. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5af036a24060..7f503ac56931 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -9525,9 +9525,10 @@ void OSDShard::_prime_splits(set *pgids) while (p != pgids->end()) { unsigned shard_index = p->hash_to_shard(osd->num_shards); if (shard_index == shard_id) { - auto r = pg_slots.emplace(*p, make_unique()); + auto r = pg_slots.emplace(*p, nullptr); if (r.second) { dout(10) << "priming slot " << *p << dendl; + r.first->second = make_unique(); r.first->second->waiting_for_split = true; } else { auto q = r.first; @@ -9646,7 +9647,10 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) return; // OSD shutdown, discard. } const auto token = item.get_ordering_token(); - auto r = sdata->pg_slots.emplace(token, make_unique()); + auto r = sdata->pg_slots.emplace(token, nullptr); + if (r.second) { + r.first->second = make_unique(); + } OSDShardPGSlot *slot = r.first->second.get(); dout(20) << __func__ << " " << token << (r.second ? " (new)" : "")