summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2017-07-24 15:13:42 -0400
committerAndy Schwerin <schwerin@mongodb.com>2017-07-24 15:15:41 -0400
commit84a658596bc62107539a07556b9c066af2fec683 (patch)
treec31ad008c63b803bed2db473e9bd96c126ad6740
parent01a38984d5c7b134b177d1b78023ed779c8b1631 (diff)
downloadmongo-84a658596bc62107539a07556b9c066af2fec683.tar.gz
SERVER-29817 Use hinted insert when building CollectionMetadata for performance.
-rw-r--r--src/mongo/db/s/collection_metadata.cpp5
-rw-r--r--src/mongo/db/s/sharding_state.cpp5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp
index cc650362677..734e55cfeba 100644
--- a/src/mongo/db/s/collection_metadata.cpp
+++ b/src/mongo/db/s/collection_metadata.cpp
@@ -84,7 +84,8 @@ CollectionMetadata::CollectionMetadata(const BSONObj& keyPattern,
continue;
}
- _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED()));
+ _rangesMap.emplace_hint(
+ _rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED()));
min = currMin;
max = currMax;
@@ -93,7 +94,7 @@ CollectionMetadata::CollectionMetadata(const BSONObj& keyPattern,
invariant(!min.isEmpty());
invariant(!max.isEmpty());
- _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED()));
+ _rangesMap.emplace_hint(_rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED()));
}
CollectionMetadata::~CollectionMetadata() = default;
diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp
index a0f0c5b1a4f..e264c82b57f 100644
--- a/src/mongo/db/s/sharding_state.cpp
+++ b/src/mongo/db/s/sharding_state.cpp
@@ -645,8 +645,9 @@ ChunkVersion ShardingState::_refreshMetadata(OperationContext* txn, const Namesp
if (chunk->getShardId() != shardId)
continue;
- shardChunksMap.emplace(chunk->getMin(),
- CachedChunkInfo(chunk->getMax(), chunk->getLastmod()));
+ shardChunksMap.emplace_hint(shardChunksMap.end(),
+ chunk->getMin(),
+ CachedChunkInfo(chunk->getMax(), chunk->getLastmod()));
}
return stdx::make_unique<CollectionMetadata>(cm->getShardKeyPattern().toBSON(),