Skip to content

Commit

Permalink
Merge pull request ceph#25434 from majianpeng/osd-getpg-reserve
Browse files Browse the repository at this point in the history
osd/OSD: preallocate for _get_pgs/_get_pgids to avoid reallocate.

Reviewed By: Xie Xingguo <[email protected]>
  • Loading branch information
tchaikov authored Dec 10, 2018
2 parents 09da420 + 9c73dcb commit cc5ff30
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/osd/OSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3983,6 +3983,7 @@ PG* OSD::_make_pg(
void OSD::_get_pgs(vector<PGRef> *v, bool clear_too)
{
v->clear();
v->reserve(get_num_pgs());
for (auto& s : shards) {
std::lock_guard l(s->shard_lock);
for (auto& j : s->pg_slots) {
Expand All @@ -4000,6 +4001,7 @@ void OSD::_get_pgs(vector<PGRef> *v, bool clear_too)
void OSD::_get_pgids(vector<spg_t> *v)
{
v->clear();
v->reserve(get_num_pgs());
for (auto& s : shards) {
std::lock_guard l(s->shard_lock);
for (auto& j : s->pg_slots) {
Expand Down

0 comments on commit cc5ff30

Please sign in to comment.