You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2018/09/06 02:00:32 UTC
[mesos] 03/03: Reserved vector capacities within Master::offer.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 82dbbc9d90079fd5134a28377e21669b2f41980e
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Wed Sep 5 14:51:39 2018 -0700
Reserved vector capacities within Master::offer.
Review: https://reviews.apache.org/r/68636
---
src/master/master.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 9179cf3..3277b57 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -9245,13 +9245,20 @@ void Master::offer(
return;
}
+ size_t offersEstimate = 0u;
+ foreachvalue (const auto& agents, resources) {
+ offersEstimate += agents.size();
+ }
// Each offer we create is tied to a single agent
// and a single allocation role.
ResourceOffersMessage message;
+ message.mutable_offers()->Reserve(offersEstimate);
+ message.mutable_pids()->Reserve(offersEstimate);
// We keep track of the offer IDs so that we can log them.
vector<OfferID> offerIds;
+ offerIds.reserve(offersEstimate);
foreachkey (const string& role, resources) {
foreachpair (const SlaveID& slaveId,