From d14221d5d6a44ea61cf7b70b232e88b058608fc6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 3 Apr 2018 21:07:23 -0500 Subject: [PATCH] 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 --- src/osd/OSD.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5af036a2406..7f503ac5693 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)" : "") -- 2.47.3